- Home /
Prevent rigidbody from colliding
Hello,
I have a rigidbody that uses rigidbody.velocity to move. However, when it hits a wall or the player it stops. How can I make it to go through walls and player, but trigger an action if it hits the player too?
Thanks! :)
Answer by IgorAherne · Jul 20, 2013 at 05:15 PM
In the bullet, in its rigid body component tick an option "is kinematic";
remove any collider component from the bullet
attach a collider to the bullet, and tick an option "is trigger".
Attach a script to the bullet that will have a function OnTriggerEnter(); inside of that function, say what must happen either to bullet, or to whatever it hits. Whatever is hit is accessible with keyword other, but only from inside OnTriggerEnter() function
P.S. whatever is hit must have a collider as well, for a bullet to detect it
http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html