- Home /
2D Shooter, Client can't transform.right the bullet but Host can !
Hello, i'm working on a little 2D Shooter game. For fire the bullet i use a
bullet.GetComponent<Rigidbody2D> ().AddForce (transform.right * Bulletspeed);
when my player is facing right and a
bullet.GetComponent<Rigidbody2D> ().AddForce (-transform.right * Bulletspeed);
when is facing left.
But, when i turn on multiplayer mode, the Host can shoot the bullet on the left and on the right but the Client just can shoot the bullet on the right, not on the left.. Sorry for my english, i'm French ! Thanks !
I quote my code :
[Command]
void CmdFire()
{
var bullet = (GameObject)Instantiate(
bulletPrefab,
bulletSpawn.position,
bulletSpawn.rotation);
if (facingRight) {
bullet.GetComponent<Rigidbody2D> ().AddForce (transform.right * Bulletspeed);
}
else if (!facingRight)
{
bullet.GetComponent<Rigidbody2D> ().AddForce (-transform.right * Bulletspeed);
}
NetworkServer.Spawn (bullet);
Destroy(bullet, 2.0f);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612150643im_/https://answers.unity.com/themes/thub/images/avi.jpg)