Hi everyone.
I cannot figure out why this is not working. I have my projectile registered in NetworkManager. I have NetworkIdentity on my projectile. I have NetworkTransform…etc. When I click the mouse button in the Host version, BOTH players spawn projectiles. When I click the button in the LAN client, NO players spawn anything. If I remove the [Command] ornament, the projectile is fired as expected. on the LAN client. But the the Host version still has BOTH players spawn projectiles. I’m losing my mind with this - it doesn’t seem that difficult as per this link:
void Update () {
if (!isLocalPlayer) return;
CmdFire();
}
[Command]
void CmdFire()
{
if (Input.GetMouseButtonDown(0))
{
Debug.Log(" fired ");
var pos = getPos(0, 1.2f, 0);
var obj = Instantiate(getProj(), pos, Quaternion.identity) as GameObject;
var objRb = obj.GetComponent<Rigidbody2D>();
objRb.velocity = v2(ProjectileForce, 5);
NetworkServer.Spawn(obj);
Destroy(obj, 2.0f);
}
}