- Home /
OnTriggerEnter vs Position Checking
I am creating enemies for a mobile 2D side-scrolling game. Here is how the enemy works - if the player is near them, the enemy shoots a bullet at them. I have two ideas how to do this - add a trigger zone (collider set to "is trigger") to the enemy game object, or, check to see if the distance between the enemy and player is less than a certain amount. Since this is a mobile game, I am concerned about hardware constraints so which method is better for quickness, speed, overhead. etc. All advice is greatly appreciated.
Answer by dannyskim · Nov 08, 2011 at 05:40 AM
You could go either way. If it's a 2D sidescroller i'm going to assume that you won't have entirely too many enemies on your screen. If that's the case, I'd personally do position checking. If you have a lot of objects on your screen at any point in the game, I'd go with a trigger zone.
Your answer
Follow this Question
Related Questions
Why is this script causing a lot of lag? 2 Answers
How to make an object jump? 0 Answers
switch prefab on collision 1 Answer
Huge Overhead with Empty Scene on iOS? 0 Answers