Setting a LookAt target for head rotation in code
Our model can look in an XY cone of rotation while swimming, but so far we haven't associated this looking behavior with any controller in gameplay. Normally, either the player controls the look, or the look is controlled by an object in the scene dynamically, using a LookAt control.
How to do it…
Fully load the Packt package by right-clicking on it in the Content Browser Packages List, then highlight the group Anims. Create a copy of the AnimTree Packt_CharTree. Call the copy MyTreeLookat.
Select the main AnimTree node and right-click on it and choose Add SkelControl Chain using b_head. Right-click on the canvas and choose New Skeletal Control | SkelControlLookAt.
In the Properties of the new SkelControlLookAt expand the Controller section and in Control Name type HeadControl. This is a name we'll reference in code. Underneath the Control Name, set the Control Strength to 1.0 so that there will be a visible effect.
In the AnimTree Editor, set...