- Home /
[Command] not working properly?
I'm using a command for shooting so that if a player shoots, he will shoot for the other clients as well.
But somehow only the host can shoot, and he also lets ALL clients shoot, the clients can't shoot at all. If I try without the command, everything works as expected, everyone can shoot, but only in their own game and not for the others. Why does the command break it, am I missing something important? The players are set to Local Player Authority.
public void Update()
{
if (!isLocalPlayer) return;
Move();
CmdShoot();
}
[Command]
private void CmdShoot()
{
if (Input.GetKey(KeyCode.W))
{
GameObject bullet = Instantiate(bulletPref, transform.position+new Vector3(0,.6f)
,Quaternion.identity);
bullet.GetComponent<Rigidbody2D>().velocity = transform.up*6;
NetworkServer.Spawn(bullet);
}
etc...
Your answer
Follow this Question
Related Questions
SyncListString not changing in a Command 0 Answers
How To Send [Command] From Mouse Input Of The Local Player 1 Answer
[Unet] Player object loses authority on scene switch 1 Answer
Transform.parent not set on clients UNET 0 Answers
"Trying to send command for object without authority" warning but the object is the localPlayer 1 Answer