Hi. Im trying to make a projectile that recieves a target Object to move towards. the idea is that the network spawns the projectile on all clients, but it’s movement is client-sided
Im using these lines to spawn and define the variable, inside a command function
[Command]
void CmdshootProjectile(string name, int damage){
GameObject projec = Instantiate (proj, transform.position, transform.rotation);
projec.GetComponent<Projectile> ().target = clickTarget;
NetworkServer.Spawn (projec);
}
On the host is able to spawn the projectiles correctly, and they move towards the target, but when another client does the same, the projectile stands still, and I get the error saying that the “target” variable on the projectile’s script is empty, and the host’s projectile doesn’t move on the client player either. How do I set the “target” variable of the projectile for all clients? What am I doing wrong?