Hi there!
I’m still learning how to deal with this amazing engine, and I got to move the Hero (only animated, 3D model I could get for free, anywhere to get more?) with the “click to move” rts-like movement, with the Vector3.Lerp function. Anyway, I couldn’t get the animations while moving to work, mainly because I don’t know where to add the animation.Play(“RunForward”); in the code.
This is the code of my movement script:
var smooth:int;
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);
}
Concerning the animated characters. Which do you think is better, to have characters animated previously by Maya, 3DMax, etc, or have 3D models rigged and animate them myself in Unity? (this taking into account development time and performance)
Thanks in advance!!