Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question OnTriggerExit doesn't work on the host.

Discussion in 'Netcode for GameObjects' started by KristenBoyGames, May 22, 2022.

  1. KristenBoyGames

    KristenBoyGames

    Joined:
    May 23, 2021
    Posts:
    38
    i have a very simple code that looks like this
    Code (CSharp):
    1.    
    2.     private void OnTriggerExit(Collider other)
    3.     {
    4.         other.gameObject.SetActive(false);
    5.         GameObject.Find("GameController").GetComponent<GameController>().playersalive.Remove(other.gameObject);
    6.     }
    7.  
    the problem is that the gameobject doen't get deactivated on the host, altho every player has the gameobject and the collider that this script is attached to.
     
  2. pixaware_pwedrowski

    pixaware_pwedrowski

    Joined:
    Oct 25, 2018
    Posts:
    116
    Trigger events are only sent if one of the Colliders also has a Rigidbody attached - do you have a Rigidbody component attached to your players?
     
  3. KristenBoyGames

    KristenBoyGames

    Joined:
    May 23, 2021
    Posts:
    38
    yes
     
  4. KristenBoyGames

    KristenBoyGames

    Joined:
    May 23, 2021
    Posts:
    38
    i fixed it, i think that the issue was that another script tried to use that gameobject so it wasn't able to get turned off. or at least i think so