- Home /
Question by
DubstepDragon · Mar 23, 2013 at 08:12 AM ·
collisionrigidbodyobjectvoxel
Turning an object into a RigidBody and applying a force on it...
I need the simplest way possible to add a rigidbody to an object upon collision. How can this be achieved?
(please consider that all my work is in c#, although a bit of java doesn't hurt...)
Thanks in advance!
Comment
Best Answer
Answer by sparkzbarca · Mar 23, 2013 at 08:51 AM
oncolliision(Collider collider)
collider.gameobject.addcomponent<rigidbody>();
mark as answerd
Answer by AlucardJay · Mar 23, 2013 at 08:54 AM
get the gameObject, then add a rigidbody component (Unity javascript) :
function OnCollisionEnter( other : Collision )
{
var otherGameObject : GameObject = other.collider.gameObject;
otherGameObject.AddComponent( Rigidbody );
}
Edit : D'oh, too slow =]