Hi there!
The only animated 3D character I could get to try this engine out is the Hero from Locomotion System,… so I created a terrain, and I wrote the following script to move it around the map with the “click to move”, rts-like movement.
var smooth:int; // Determines how quickly object moves towards position
private var targetPosition:Vector3;
function Start () {
targetPosition = transform.position;
}
function Update () {
var playerPlane = new Plane(Vector3.up, transform.position);
var rayo = Camera.main.ScreenPointToRay (Input.mousePosition);
var puntochoque = 0.0;
if(Input.GetKeyDown(KeyCode.Mouse0))
{
if (playerPlane.Raycast (rayo, puntochoque)) {
var targetPoint = rayo.GetPoint(puntochoque);
targetPosition = rayo.GetPoint(puntochoque);
var targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
transform.rotation = targetRotation;
}
}
smooth = 5.0;
transform.position = Vector3.Lerp (transform.position, targetPosition, Time.deltaTime * smooth);
}
But now I’d like to add the animation of “RunForward” (incorporated in the model) in this code in order to get the walking animation while the character is moving. Maybe the way I use to move the character isn’t the proper one…
So, how could I add the animation?
Thanks in advance!