uses the attribute [client] but is not a network behaviour

I have a simple raycast method for shooting:

void Shoot ()
{
RaycastHit _hit;
if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, weapon.range, mask))
{
if (_hit.collider.tag == PLAYER_TAG)
{
CmdPlayerShot(_hit.collider.name);
}

        //We hit something
        Debug.Log("We hit " + _hit.collider.name);
    }

The compiler returns UNetWeaver error: Script PlayerShoot uses the attribute [client] on the method shoot but is not a network behaviour.
It seems like I’m misunderstanding how this works??? The intended purpose is to have that method to be called on the client.

1 Answer

1

Idk if you still need help with it but other ones can have a problem with it. Solution is to change MonoBehaviour class to NetworkBehaviour like this:

public class YOURCLASSNAME : NetworkBehaviour{ //Instead of YOURCLASSNAME : MonoBehaviour
// Your code
}