MultiplayerFPS-Tutorial icon indicating copy to clipboard operation
MultiplayerFPS-Tutorial copied to clipboard

E.13 (Muzzle Flash)

Open DoodyDan opened this issue 2 years ago • 0 comments

Hi,

I'm getting an error:

NullReferenceException: Object reference not set to an instance of an object PlayerShoot.Update () (at Assets/Scripts/PlayerShoot.cs:32)

This happens once a second player enters the network. The line that gives the error is:

    if (currentWeapon.fireRate <= 0f)
    {
        if (Input.GetButtonDown("Fire1"))
        {
            Shoot();
        }

After Debugging - it seems that currenWeapon is assigned when the host is playing in the server - but as soon as a second client joins, this reference gets broken. Any ideas?

Here is my PlayerShoot Script: https://www.codepile.net/pile/BNWvbZRM Here is my WeaponManager Script: https://www.codepile.net/pile/d3orgj1D Here is my PlayerWeapon Script: https://www.codepile.net/pile/L8m56W8J

DoodyDan avatar Sep 30 '21 13:09 DoodyDan