Waypoint System Does Not Rotate Enemy?

Hello,

My waypoint system does not rotate my enemy according to the direction of the waypoint. Here is my script:

var waypoint : Transform[];
static var speed : float = 5;
private var currentWaypoint : int;

function Update () 
{
    if(currentWaypoint < waypoint.length)
    {
        var target : Vector3 = waypoint[currentWaypoint].position;
        var moveDirection : Vector3 = target - transform.position;
        var velocity = rigidbody.velocity;

        if(moveDirection.magnitude < 1)
        {
            currentWaypoint++;
        }
        else
        {
            velocity = moveDirection.normalized*speed;
        }
    }

    rigidbody.velocity = velocity;
}

Any suggestions why? Thanks. Ollie

You could add

transform.LookAt(currentWaypoint);

right after you set rigidbody.velocity

Edit (To set it to only rotate around x):

var lookAt = currentWaypoint.position - transform.position;
lookAt.x = 0; //if you want to rotate around only y, set lookAt.y to 0 instead

transform.rotation = Quaternion.LookRotation(lookAt);

Am sorry I dont know the answer to your question but here I need some help , =(

I have a question to you "Oliver Jones" . Can you please tell me how to add enemy Ai , what tutorials you are following please give me some guidelines .