Game Development Reference
In-Depth Information
ikSolver.Solve( bonesR, desiredRightWristPosition );
handR.rotation = QuaternionFromMatrix(gun.
localToWorldMatrix * rightHandMat);
//Left arm
var desiredLeftWristPosition: Vector3 = (gun.
localToWorldMatrix * leftHandMat).
MultiplyPoint3x4 (;
var bonesL: Transform[] = new Transform[3];
bonesL[0] = armL;
bonesL[1] = forearmL;
bonesL[2] = handL;
ikSolver.Solve( bonesL, desiredLeftWristPosition );
handL.rotat ion = QuaternionFromMatrix
(gun.localToWorldMatrix * leftHandMat);
Step 12. Play. Drag the target sphere around in front of the
character and note how the shoulders, elbows, and wrists bend to
accommodate the orientation of the gun. The ikSolver.Solve() function
does this by taking all the bones and the desired location of the end
effector and calculating the best angles. Some angles are obviously
undesirable, such as if the target goes behind the character. When this
occurs, other techniques, such as turning the entire character around
or changing her pose, are desirable.
Step 13. To end this workshop, we will add in some other
animations based on the angle to the target such that when it
is up high the AimUp animation will be used and when low the
AimDown animation will be set. The character will also turn around
automatically to face the target location. This requires a small
change to the Update() function of animationController, as shown in
Listing 3.17 .
Listing 3.17 Adding More Appropriate Upper Body Poses
to Match Arm Direction
function Update ()
//modify orientation and aim pose based on location of target
var direction = ai mPoint.transform. position -
Search Nedrilad ::

Custom Search