- Home /
a rigid body without physics?
hello, i have a situation were i need an object to collide with another object and the two to just stop and do nothing. as in, not to bounce away from each other but not pass through each other.
i have the two objects with box colliders, one kinematic and one not. i learnt that if both are kinematic they just pass through each other. So is there a way to have both objects kinematic, and so not affected by physics, but not to pass through each other?
thanks in advance! might be a noobish question
Answer by Bunny83 · Jun 06, 2011 at 12:35 AM
Physics is what they made to not pass through each other. If you control the objects yourself (kinematic rigidbodies) there's nothing what the collision system could do when you move one into another. Physics can apply forces to prevent intersection.
What you can do is to turn the collider into trigger. Then you can check for collisions yourself.
A Rigidbody represents a physics object nothing else. A kinematic rigidbody is just a tool that allows one-way physics interactions.
edit
It should also be possible to use Rigidbody.SweepTest or Rigidbody.SweepTestAll with kinematic rigidbodies. It just simulates the movement and tells you if and where it would collide but doesn't move it actually. That way you can handle the collisions the way you want.
At least one of them still needs to be a rigidbody, or else OnTriggerEnter won't fire.
my thinking is that he's potentially using rigidbodies for a reason (maybe a physics marble game or something like that), and needs an object to act like a stopper.. which is why I suggested zeroing out the velocity as a simple solution.
Well, if you read it literally sure. But I like to give people the benefit of the doubt- if they're using a rigidbody, I assume they have a reason for it unless it's phrased in a way that leads me to believe that they're utterly lost ;)
Answer by testure · Jun 05, 2011 at 11:22 PM
You could always check for collision via raycast, trigger, or any other relevant method, and then if it's detected, zero out your velocity. That would probably be the simplest method.
@testure that sounds like what i am after. thank you, how do i zero out velocity?
never $$anonymous$$d my other question has already been asked! thanks for all the help guys answers.unity3d.com/.../how-do-i-zero-out-the-velocity-of-an-object.html