- Home /
Question by
LittleCat1 · Mar 27, 2012 at 11:06 AM ·
movementrigidbodyrespawn
Movement continues after respawn
Hi, I've currently got an issue where, after respawn, the momentum my character had as he died (falling off an edge) is maintained.
I thought maybe I could disable and then enable rigidbody, but that breaks the game as I have a script reliant on it. Is there a work around?
A similar thing happens when touching a joystick as the scene spawns (could I kill two birds with one stone and make a movement 'null' kinda thing?)
Currently using javascript
Thanks for being amazing
Comment
Best Answer
Answer by Kryptos · Mar 27, 2012 at 02:18 PM
You can temporarily set the rigidbody as kinematic. This will nullify any remaining forces applied to your object.
rigidbody.isKinematic = true;
yield; // wait one frame
rigidbody.isKinematic = false;
Or you can reset the velocity:
rigidbody.velocity = Vector3.zero;
rigidbody.angularVelocity = Vector3.zero;
Or you can set an artificially big drag:
rigidbody.drag = 100;
There are different alternatives...