- Home /
Efficient collision detection for a runner game
I'm making a 3D runner game for mobile devices (like temple run), and I want to know how should I check the collisions in an efficient way. In my game, there will be around a maximum of 15-20 obstacles active at the same time to check collisions with, plus some items/powers ups. All of them have simple colliders, like boxes or capsules. So, the question is, should I use... A) physics system (this is, onColliderEnter function, and all similar things). B) checking if colliders near to player overlaps with it every frame, with something such as: collider.bounds.Intersects(...) C) Some cast from the player, like a capsuleCast, or some rayCasts every frame and checking the distance of collision point. D) Any other option that I haven't thought of.
Thank you very much!
Answer by Lockstep · Jan 31, 2014 at 05:15 PM
Physics!
Unity uses the PhysiX engine by envidia. I'd say it is pretty optimized. Read the documentation on collider for information on how to set it up.
I know how to work with physics. What I'm not sure if it's the best solution for my project, since it's a game for mobile devices and everything must be optimized the most it can be. I'm a little scared that using physics some of the collisions may be undetected in some low-end devices(tunnelling), or maybe slow the game down
A grown-up collision system, which I assume Phys-X is, uses 20+ years of known speed tricks.
For example, an Octree groups the space into big chunks, and you only check your chunk for overlaps. So if you're nowhere near anything else, collision checks are 0 time. They were made to replace the "check everything every frame" method you proposed.
Your answer
Follow this Question
Related Questions
What is the best practice in handling scenes with 100+ rigidbodies and collisions on iOS? 1 Answer
Massive framerate fall with Character Joint 0 Answers
Is PhysX being used on mobile 1 Answer
Physic spikes after few seconds of gameplay on Android 0 Answers
What event gets called on resuming a game on mobile? 1 Answer