5
\$\begingroup\$

The target platform of my game is mobile devices therefore I try to develop it performance oriented. It will be a strategy game so I don't really need physics in it, consequently I did not add RigidBody to my object to avoid unnecessary computations. However according to the Box Collider reference page, the collison event cannot be triggered, unless one of the objects is a RigidBody. Is there a simple way to check collision between objects other than using RigidBodies? Or can it be that I'm overreacting this performance thing and the physics engine won't slow my game down?

\$\endgroup\$

1 Answer 1

8
\$\begingroup\$

What you're doing sounds a lot like premature optimization to me. Did you try using the physics-engine and did it actually turn out to cause performance issues?

If you don't need the physics-simulation and just care for the collisions, why not use sensors (or "triggers", as they are called in Unity). For stationary objects, use a collider with the Is Trigger checkbox ticked. For moving objects do the same, but also add a rigidbody and set it to be kinematic.

That way you'll only get collisions out of the engine and no other simulation is necessary (use the OnTrigger... callbacks instead of the OnCollision... ones).

If you only need to detect collisions in 2D and the physics engine really turns out to cause performance issues (I highly doubt that, but I have no clue how your game looks like), then you could probably get away by representing your entities as circles and just do a very fast circle vs. circle test?

\$\endgroup\$
1
  • \$\begingroup\$ my question still is "How to detect collision in Unity3D without rigid bodies?" \$\endgroup\$ Commented Jun 14, 2016 at 8:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .