I'm trying to create a "tree felling" effect, where the tree trunk falls over after being cut down by the player. I've used one prefab which contains my tree stump and tree trunk as children.
In its default state, my tree trunk as a rigidbody with
isKinematic=true. When the player cuts down the tree, I begin an animation on the trunk which "tips it over". On the last frame, it sets
isKinematic=false - at this point it should "fall over" because physicals/gravity is in control and the center of mass is definitely over its base.
However, the animation seems to be preventing it, like it's still "controlling" the transform.
- Adding a transition from the "fell" state to an "exit" state just resets the position/rotation.
- Setting the animator to "animate physics" kind of works, but the tree just flies away, probably colliding with the stump or something.
- Disabling the animator after the animation kind of works, but this also causes the tree to go flying with some crazy physics.
- When left alone,
OnCollisionEnteris called on the tree for colliding with my ground, yet the gameobject appears to still be stuck at 45 degrees and never touched the ground. It seems like the rigibody/collider is not where the mesh/transform is?
Animating the object and then turning off isKinematic should work, it's been recommended to me on reddit and is the accepted answer on this question, so I'm not sure what could be wrong.
Edit: I can ease the physics problems by telling the trunk to ignore it's own stump (
Physics.IgnoreCollision(Trunk.transform, Stump.transform);), but the base of the tree still "jumps" away from the stump, rather than "continue tipping over". I'm not sure what else could be at play.