- Home /
Added rotation AFTER the rotation from animation clip ( rewarding 400 points to whoever solves this)
Hey :)
How can I add my rotation to any bone of the rig? For example, twist the spine1 by 45 degrees (or any other amount) after I press "R" key.
This has to be done as an additive rotation, applied after the animation clip that's currently playing.
Thank you very much!
So we have a skeleton which has "breathing" animation playing. I would like to twist the spine in addition to the animation transformations, without stopping them. The order of me applying my rotation (before the animation or after) is not important to me
Answer by tanoshimi · Dec 27, 2015 at 03:47 PM
Update() is called before animation changes, but LateUpdate() is called after. So if you want to override any animations you should just put them in LateUpdate(). Something like this:
void LateUpdate() {
// Find the bone to adjust
Transform head = transform.Find("Armature/Hips/Spine/_Spine1/_Spine2/Neck/Head");
// Target is the main camera
Vector3 targetPos = GameObject.Find("Main Camera").transform.position;
// If the player presses "R"
if(Input.GetKey(KeyCode.R){
// Set the head rotation to look at the camera
head.rotation = Quaternion.LookRotation(targetPos - head.position);
}
}
Thank you, excellent advice! Rewarded 400 points to you for your help