How it works...
You might have noticed that all the code invoked for rotating the character's spine is inside the LateUpdate() method, as opposed to the more common Update() method. The reason for this is to make sure that all the transform manipulation will be executed after the original animation clip is played, overriding it.
Regarding the spine rotation, our script adds the horizontal and vertical speed of the mouse to the xAxis and yAxis float variables. These variables are then constrained within the specified limits, avoiding distortions to the character's model. Finally, the spine object transform rotations for the x and y axes are set to xAxis and yAxis respectively. The z axis is preserved from the original Animation Clip.
Additionally, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access