- Home /
The rigidbody component in my object won't reset.
Hello and Thank you in advance.
I'm beggining to experiment with object pools and it's been a fairly difficult path. I coded a spawn system that takes the objects in the pool and makes them spawn in different locations by using the "setActive()" method. The method is used whenever the objects are moved from the objectpool position to the spawnposition. Every object in the pool has a rigidbody component. When the objects are activated, the Start method kicks in and I add force to its rigidbody. If the player touches the object, or the object touches the boundarys I set up, the object is set back to "setActive(false)"
The Problem
After the object is set back to "setActive(true)" once again, the speed, momentum and direction keep going from where it last left off. Isn't it supposed to reset itself after the object is deactivated? Is there a way to reset it through code?
Answer by Linus · Feb 20, 2014 at 11:41 PM
rigidbody.velocity=Vector3.zero
http://answers.unity3d.com/questions/55644/easy-way-to-remove-all-velocity.html
Doing that right before disabling it, or right after activating it should work. As mentioned in the linked question you also need to reset anything causing force to the object.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
character joint scripting HELP!!! 1 Answer
Delete object when two collision or more 1 Answer
Reloading Help 2 Answers
Player lives script help 1 Answer