Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to animate rigidbody objects in Unity

I'm creating a game in which I need to move an object straight up, and when it hits another object they are connected with joint. That's why I need to have rigidbodies attached to both of them. The problem is that when I use animation to do this, collision is not detected, and unity tends to crash. Is there any proper way of "animating" rigidbody objects? Or maybe I should choose a different approach?

like image 659
clone Avatar asked Oct 26 '25 19:10

clone


1 Answers

Set Rigidbody.isKinematic to true on the rigid bodies just before animating them. This will allow you to move (animate) the rigid bodies by changing the transform.position and other properties while allowing collisions with other non-kinematic bodies(rigid bodies with isKinematic set to false) and joint constraints to work properly. When the animation has completed and you want the bodies to be affected by physics again, set isKinematic to false.

Refer to the documentation for isKinematic for more information and a ragdoll example.

like image 134
EvilTak Avatar answered Oct 29 '25 09:10

EvilTak