- Home /
Changing Rigidbody Drag on Collision
How can I change the drag on a rigidbody when it collides with anything in the world/map?
I'm currently making a sort of spell working like the staff of magelight from skyrim were the magelight(projectile) stops on collisison!
Answer by ZorNiFieD · Dec 31, 2012 at 12:43 AM
if (hit){
rigidbody.drag -= 1;
rigidbody.angularDrag -= 1;
}
Some sample code you are using would help to answer this question. My answer is very vague and assumes you already have a hit variable setup and a rigidbody attached to the GameObject from which the script is attached.
Or if you just want the rigidbody to stop dead in it's spot, just set the following:
rigidbody.is$$anonymous$$inematic = true;
Great answer! One more thing you could do, is set the rigidbody's velocity to zero on all three axes.
rigidbody.velocity = Vector3.zero;
or in C#,
rigidbody.velocity = new Vector3(0, 0, 0);
Your answer
Follow this Question
Related Questions
How to move a tank? 1 Answer
Objects with colliders going through walls and each other. 3 Answers
Drag Rigidbody that respects collisions. 1 Answer
Problem with Object collision 1 Answer
How to get movable/pushable cubes right? 0 Answers