Game Development Reference
In-Depth Information
How to do it...
1. First of all, we need a new
Node
instance called
centerPoint
in our
GameCharacterControl
. This will be the origin of our leaning, so to speak:
private Node centerPoint = new Node("Center");
2. We set the translation to be pretty much in the center of the character's body (half
the distance to the camera). We also attach the head node to
centerPoint
. In
the
setSpatial
method, we add the following lines of code:
if(spatial instanceof Node){
((Node)spatial).attachChild(centerPoint);
centerPoint.setLocalTranslation(0, 0.9f, 0);
centerPoint.attachChild(head);
}
The following figure shows you the relation between the
head
and
center-
Point
nodes: