- Home /
2 isTrigger Colliders (2D)
Hi, so I am making a 2D game, and I have an enemy which will spawn in and go to a certain spot. These enemies have a circle collider with isTrigger that is bigger than them, and when the player is inside that collider, they follow the player until the player leaves that area. The player can attack the enemy, but I want the enemy to have a separate box collider so it can detect when the player hits them. (I want the OnTriggerEnter2D to trigger for the box collider and not the circle collider sometimes). Is there any way to do this?
Answer by n_rusev · Apr 04, 2020 at 04:34 PM
This is a bad way to do this. You can instead use the Vector3.Distance function to find how far away the player is, and create your following logic around this function, and use the Collider for hitting.
Here is an example of how it works: Unity Scripting API: Vector3.Distance
Your answer
Follow this Question
Related Questions
Multiple Stacked Colliders only register for single object 0 Answers
Collider2D/RigidBody2D not working 1 Answer
Cirlce Colliders 0 Answers
There seems to be a collider when there shouldn't be 1 Answer
Ignore collision at high velocity. 1 Answer