- Home /
Trigger and Collider?
Hello! So I am making an enemy that when the player enter its trigger, it prints Hello! (Just for a test) How would I make it where it does that, but the enemy still doesn't allow the player to move through it. Thanks!
Answer by lrb · Nov 28, 2017 at 11:48 PM
Hi,
You could do this just by stop walking when hit enemy trigger or creating an hierarchy of GameObjects that do this trick one inside other or adding more than one Collider on the same GameObject, some trigger and some not.
Answer by Darkforge317 · Nov 29, 2017 at 12:06 AM
Not sure if you're 100% set on keeping the trigger.
If you're able to ditch the trigger, then just make it a regular Collider. No trigger. And then use OnCollisionEnter instead of OnTriggerEnter.
But if you're 100% set on keeping the trigger. Then add a new Empty GameObject as a child of your enemy, then make that empty game object have a Collider on it.
That way you have both a trigger and a Collider.