Game Development Reference
In-Depth Information
How it works...
When selecting a bone to apply the leaning to, it should be close to the base of the upper
body of the character. On Jaime, the spine is a suitable bone.
When Bone.setUserControl(true) is called, we tell the bone that no animations
should be applied and that we will handle any rotation or translation manually. This has to
be called before we set the rotation, or an exception will be thrown. Likewise, when we're
done, we need to call setUserControl(false) to give the control back to the user
(or no animation would be played).
Manually controlling bones is powerful and can be useful for many different applications,
such as precision aiming and head tracking. Getting everything right can be tricky,
however, and most likely it's not something that you will do frequently.
This class can be used separately from Chapter 2 , Cameras and Game Controls , or they
can be merged together. The benefit of having them separate is that we can also apply them
separately. For example, the player's own character in a FPS won't need this control since
you would never see it lean anyway. In this case, it's all about the camera. However, other
players in the same (networked) FPS will need it, as would AI enemies who might use the
same character control class.
To learn more about how leanValue is used and applied, have a look at the Leaning
around corners recipe of Chapter 2 , Cameras and Game Controls .
Search WWH ::




Custom Search