Game Development Reference
In-Depth Information
Step 5. Set each of the values for the transformations by locating the
script attached to the Hero game object and dragging and dropping
the appropriate child objects from the Hero onto the values in the
Inspector as shown in Figure 3.14 .
FIG 3.14 Attaching model bones to
script variables.
Step 6. Before moving the arm bones into position, the end effector
(gun) needs to be positioned. As it is going to point at the target, we
can use the LookAt() function to change its orientation. The LookAt()
function will rotate the object such that the positive z axis (the blue
arrow) is pointing toward a target. If you click on the right gun in the
Scene, you will notice that the blue axis is not aligned with the barrel
of the gun. In this case, if you just use LookAt() it will orientate the side
of the gun to face the target. This means after using LookAt() we have
to make a 90° adjustment to get the barrel of the gun pointing at the
target. To achieve this, add the new function in Listing 3.14 to the end
of animationControls.js.
Listing 3.14 A Late Update Function to Change Orientation
of a Game Object under Animation Control
private var speed = 0.01;
...
function Update()
Search Nedrilad ::




Custom Search