Search Unity

OnTriggerEnter2D just work once, and then stop working

Discussion in 'Physics' started by NicolasPCouts, Feb 20, 2019.

  1. NicolasPCouts

    NicolasPCouts

    Joined:
    Jun 27, 2017
    Posts:
    1
    I am working on a feature that works in this way, when the player presses a "x" key, a gameobject is enabled and this gameobject have a script that checks if something collided with him using the OnTriggerEnter2D method, and after 3 seconds the player script disables this gameobject.

    Its a attack, but the problem is that, when this gameobject is enabled for the first time everything works fine, the OnTriggerEnter2D method gets called and works. But when the gameobject is enabled again, it doesn't work, unless i move the player from the place that the method was activated for the first time.

    So, what i think its happening is that the OnTriggerEnter2D method is not being called again because the OnTriggerExit2D method was never called.

    How can i reset the OnTriggerEnter2D method to work again everytime that i enable this gameobject? because i really don't have a clue
     
  2. Bernis

    Bernis

    Joined:
    Mar 6, 2018
    Posts:
    2