-1

I know there are so many questions about this topic but they didn't fix my problem. I'm making a multiplayer game and there can be many client. When First client attended game it is okay but when second client attended the game I'm having this error. How can I fix it? Thank you.

Here is my code:

    public GameObject ant;
PlayerMove move;
NetworkManager manager;
void Start()
{
    move = ant.GetComponent<PlayerMove>();
    manager = GameObject.FindGameObjectWithTag("NetworkManager").GetComponent<NetworkManager>();
    
}

Here is the PlayerMove script:

 public void GeriGit()
{
    PlayerRb.AddForce(0, CarpmaKuvveti, 0, ForceMode.Impulse);
    StartCoroutine(HizSifirla());
}

these codes are not working when i get the error And here is the error lines:

private void OnTriggerEnter(Collider other)
{
    if (other !=null && other.tag !=null)//I tried this code to fix it but it didn't work for me.
    {
        if (other.tag == "taban")
        {
            move.GeriGit();
        }
    }

}
whyme
  • 11
  • 3
  • 1
    Use Debug.Log before the line that throws the NRE. Check all possible variables that can be null to figure out which one is null. Your question is likely to be closed quickly, since NRE is asked everyday, and there are tons of explanations of how to debug and solve it. – hijinxbassist May 05 '22 at 21:13
  • `move` is null. I'd recommend setting some breakpoints and stepping through your code. `move` can only be `null` if `ant` is null - which would throw an NRE in `Start()`, or `ant` doesn't have a component of type `PlayerMove`. – 3Dave May 05 '22 at 21:19

0 Answers0