OnTriggerEnter2D on Attacker and Lizard

Hello

For the Lizard Object there are 2 different instances/implementations of function “void OnTriggerEnter2D (Collider2D collider)” in Attacker and Lizard scripts. How does the game engine select which copy of the function to implement when Lizard is triggered after a collision? I didn’t see anything about derived class/inheritance info in the code.

Because my Lizard object is implementing the one in the Attacker.cs, not the one in the Lizard.cs. Hence he is not attacking. Thank you

I had a mistyping of the function in Lizard.cs . Had to type OnTriggerEnter2D but typed OnTriggerEnter2d.

Now both of the functions in Attacker.cs & Lizard.cs trigger. Sorry for the interruption :sweat:

Remember that the order of execution of the OnTrigger events is based on the position of the scripts in the inspector of your game object, too, from top to bottom.

1 Like

That is a quite important tip. Thank you Galandil

Privacy & Terms