Bolt Instantiate - Sceneobject reference
Options
in Photon Bolt
Hello,
I have a small problem
I want to instantiate a bullet which moves forward (done)
But this bullet diesnt get the reference to the player (GameObject.find) doesnt work since theyre called all the same (Player Clone)
BoltEntity entity = Boltnetwork.instantiate....
Entitiy.getcomponent........... = player(is referenced in my gun object) doesnt work also, its just "nothing" in the editor window...
I need it to get the speed and damage from the player and to send the exp from the attacked object if it gets destroyed...
I have a small problem
I want to instantiate a bullet which moves forward (done)
But this bullet diesnt get the reference to the player (GameObject.find) doesnt work since theyre called all the same (Player Clone)
BoltEntity entity = Boltnetwork.instantiate....
Entitiy.getcomponent........... = player(is referenced in my gun object) doesnt work also, its just "nothing" in the editor window...
I need it to get the speed and damage from the player and to send the exp from the attacked object if it gets destroyed...
0
Best Answer
-
You are going to hit road blocks very quickly without understanding things like ownership (covered here http://doc.photonengine.com/en-us/bolt/current/in-depth/entity-ownership )
From what I can tell from your code snippet you are trying to reference a player, however this "player" variable who is the target of the shot will not be set in proxies, causing it to be null. You can either network this target using a token or setting the targets as a state property of the shot.5
Answers
-
Can you clarify what you're trying to do?0
-
public void Shoot() { foreach (Transform gunpvt in gunPivots) { BoltEntity shot = BoltNetwork.Instantiate(BoltPrefabs.Bullet, gunpvt.position, gunpvt.rotation); shot.GetComponent<BulletMovement>().player = player; }
Basically i am instantiating an bullet, which moves forward
And i want the "player" variable be assignet with the shooting player (Player)
But it tells me always "Object reference not set"0 -
Is your game server authoritative? Is this code being run on the host and the client?0
-
Ahm no idea
The server is a player... if that helps somehow...0 -
Who owns players in your game, client or the host?0
-
In short: i have no idea... just started adding stuff like transform replication and variables - nothing more0
-
You are going to hit road blocks very quickly without understanding things like ownership (covered here http://doc.photonengine.com/en-us/bolt/current/in-depth/entity-ownership )
From what I can tell from your code snippet you are trying to reference a player, however this "player" variable who is the target of the shot will not be set in proxies, causing it to be null. You can either network this target using a token or setting the targets as a state property of the shot.5 -
Tryed already to set it as entity state but that doesnt work either
But im going to look deeoer first in everything, its the best i think0