So I have a problem with this code, I want the enemy to rotate to look at the next waypoint. I tried this:
transform.LookAt(waypoints[waypoint].position);
But this makes it just kind of jump, I want the enemy to visably rotate. This is my code now:
void NextWaypoint()
{
waypoint++;
if (waypoint >= waypoints.Length) //if the enemy has reached the end of the waypoints
{
waypoint = 0; //starts again at 0
}
Vector3 directionTowaypoint= transform.position - waypoints[waypoint].gameObject.transform.position;
Quaternion enemyRotationtowaypoint = Quaternion.LookRotation(directionTowaypoint);
transform.rotation = Quaternion.Slerp(transform.rotation, enemyRotationtowaypoint, Time.deltaTime * 10);
}
Would appreciate some help!