A couple of doubts on my RTS

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!!

You can put it in here.

if (playerPlane.Raycast (rayo, puntochoque)) {
    var targetPoint = rayo.GetPoint(puntochoque);
    targetPosition = rayo.GetPoint(puntochoque);
    var targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
    transform.rotation = targetRotation;
}

When you click the point to move to, your character will play the animation. Most likely, you’d want the walk animation to loop until it reached its destination, and once it has, stop the animation.

That made it! Thanks!

But I realized that this way of doing this wouldn’t take me to my goal, so I created another thread asking more abstract, basic questions about it.

Thanks anyway, this is the new thread, in case you wanted to read it:
http://forum.unity3d.com/threads/100138-WarCraft3-like-movement-developing-kind-of-a-RTS.?p=656025#post656025