Set bone transform in code after removing skinnned mesh renderer and adding mesh renderer.
I have a skeleton. it's is not animated outside of unity. Using an animation pack. I can change the bone rotation with code, but it only seems to work in LateUpdate.
What i am trying to do is when the skeleton is killed. His bones fall apart into a pile on the floor. But instead of using the last frame of it's animation, it flips to a T-Pose.
i have and can get each bone(mesh) in code. And even can get the actual HumanBodyBones in code. each bone(mesh) has on it a skinned mesh renderer, a rigidbody, mesh collider, mesh filter and a custom script to control it.
order of sequence at death of a skeleton: using a coroutine..
i stop the animation. Pause
then i save each bone position rotation localeulerangle in a separate dictionary.
i turn off SkinnedMeshRenderer(for each bone(mesh) in model).
i add MeshRenderer.
i add meshfilter and fill with appropriate mesh.
apply the values from the dictionaries to the bones.
turn on gravity(rigidbody).
I am expecting the skeleton to just collapse into a pile of bones, but it shoots to T-Pose and then collapses into a pile of bones. it's jarring to look at.
but no matter how i try to apply the rotation, transform, localeulerangles, ect., it will not hold on to the values of the last frame of the animation. i even tried to do it with without saving the values and reapplying. nothing seems to work.
TLDR;
Just trying to get a skeleton figure to fall into a pile of bones with the transforms and rotation applied to the bones so it had the last frame of animation before it's death.
any help would be appreciated. thanks.
Your answer
