P
P
Pragma Games2021-12-06 17:07:21
Unity
Pragma Games, 2021-12-06 17:07:21

How to make the OnTriggerExit event fire?

Hello. There is a turret that has a sphere with a trigger collider, when a monster hits it, the turret starts shooting at it (More precisely, according to the position where the monster itself is located, the turret does not have the essence of monsters), while adding the monster's transform to the list with the monsters that are currently in collider. When a monster dies, it is disabled and sent to the pool. The problem is that when the monster is disabled, the OnTriggerExit event does not occur on the turret collider, and the turret seems to think that the monster is still in its field of view. How to solve this trouble? The monster has a collider and a rigidbody.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Ente, 2021-12-06
@PragmaGames

Before disabling the object, you can shift it to large coordinates, like (-99999, 0, 0), then the function will work as it should. Crutch, but it works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question