How it works...

We are using the same principle as in the Using LookRotation() and SetLookAtPosition() methods to make characters follow an object with their gaze recipe. Our script rotates the chest bone in such a way that the character appears to aim at the target. We use the Additional Rotation vector in the CharacterLookAt.cs script to adjust the rotation (chest is not facing straight forward in most animations). This way of aiming is good for games in which characters walk relative to the camera (it is suitable for TPP games with an over-the-shoulder camera). It fails when characters have to rotate more than 50-60 degrees. The next recipe solves this problem.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.126.211