- Home /
Crate smashing, pooled object causing issues with rigidbody
I have a crate in my scene with the following hierarchy:
Each plane corresponds to a separate piece of the crate, when I collide with my normal crates, I have an animation that will throw these pieces into the air and back down. This issue arises when the animation is finished. I have a rigidbody on each plane, so the pieces have their own physics.
I have pooled 20 of the objects below and when I collide with a normal crate, I set the first crate to active, play the animation and then let physics take over. The first one always works fine, but if I draw the same crate again from the pool, the next time the physics take over, the pieces fall downward at lightning speed, almost to the point I cant see it happening.
If I normally Instantiate the smashed crates, they work accordingly but I would preferably like to use pools as I'll have a lot of crates in my game. If anyone knows why this is happening, I would greatly appreciate it.
Answer by RLin · Aug 01, 2015 at 09:05 PM
When placing the smashed crates back into the object pool, they keep their velocity. You must set each crate's velocity to zero once it is pooled, otherwise it will continue at the same speed it was travelling at when it was placed in the pool.
Can't thank you enough for this answer, this was exactly it, thanks a million
Your answer
