Killing player in multiplayer

Hello Unity!!!

So I have 2 scripts:

  • NetworkManager

  • BullettCollide

In the network manager it contains a

    public void KillPlayer() {
//stuff
}

in the BullettCollide contains this:

if (col.gameObject.tag == "Player")
        {
//GET THE PUBLIC VOID KILLPLAYER TO PLAY HERE
        }

So does anyone know how I could have the others scripts public void play in the bullett collide script.

Thanks in advance!

It’s easy. I suppose that your network Manager script is in an empty GameObject… let’s say called “Network Manager”. You simply do this: NetworkManager netManager = GameObject.Find ("Network Manager").GetComponent<NetworkManager> ();.

You could also replace GameObject.Find () with GameObject.FindObjectWithTag () which is more “elegant”. Then you simply call the method: netManager.KillPlayer ().

You should follow this series about making an FPS using Unity network

Cheers.
Luna~