Image
Top
Menu
July 8, 2010

Unity Beginner Tip of the Day: Rigidbody Required for Collision/Trigger Events #Unity3D

“If you are moving a GameObject through its Transform component but you want to receive Collision/Trigger messages, you must attach a Rigidbody to the object that is moving.”


From unity3d.com – Unity Reference Document: Rigidbody

This might seem obvious. The rigidbody component is used when you want your game object to have physics applied on it. Unity has Ageia (now part of Nvidia) physX engine built-in, so you can easily make a game with physics in it – stuff like gravity, realistic collisions, forces, and torque. It can create some very impressive and natural-looking effect. (similar to Little Big Planet or this Unity-powered gem Cordy)

But what if you don’t want the fancy physics? You can simply remove the rigidbody component in your game. However if you have any collision or trigger messages in your game, that is, if you use any OnCollision or OnTrigger functions, they will no longer work. As stated at the bottom on the Rigidbody reference page, “If you are moving a GameObject through its Transform component but you want to receive Collision/Trigger messages, you must attach a Rigidbody to the object that is moving.”

So the bottom line is, if you don’t want to use physics for the objects in your game but need to have collisions and triggering events, keep the rigidbody component on the objects and Enable “Is Kinematic” – which disabled the object from having physics applied to it.

Posted via email from Brandon Wu’s Road to Where He Wants to Be


  • danny

    It seems that triggers require rigidbodies to have “idKinematic” disabled, or at least i can’t get it to work.

Posted By

Categories

Blog Posts, Unity3D

Tags