Game Development Reference
In-Depth Information
//create a line from the mouse position into the screen
var ray = Camera.main. ScreenPointToRay(Input.
mousePosition);
var hit : RaycastHit;
//determine where it hits something
if (Physics.Raycast (ray, hit, 100))
{
//put the aiming object at that position
aimPoint.transform.position = hit.point;
}
}
...
}
Step 3. Play. A red-colored sphere will appear on the terrain at the
mouse location. It will appear to move around if you hold the left
mouse button down and move the mouse. In this case the target is
a primitive sphere; you could of course add any model you like by
instantiating a game object.
Step 4. Next, the IK calculations need transformations of the bones
and the end effector. Include these as variables at the top of the
animationControls script as shown in Listing 3.13 .
Listing 3.13 Adding Arm and End Effector Transformations
for IK Calculations
private var speed = 0.01;
private var turnSpeed = 20.0;
private var aimPoint: GameObject;
//For IK----
//right arm bones
var armR: Transform;
var forearmR: Transform;
var handR: Transform;
//left arm bones
var armL: Transform;
var forearmL: Transform;
var handL: Transform;
var gun: Transform; //end effector
function Awake()
{
...
Search Nedrilad ::




Custom Search