How to play an animation with waypoints

Hi there I am creating an underwater game, and I have set up a waypoint system for a fish model. The waypoint script works okay, but the fish is facting the wrong direction when it moves. So I added a simple animation to it, now it does not move. How can I have the fish move in the waypoint system and still have the animation play?

Here is my script: `var waypoints : Transform;
private var current_waypoint : int = 0;
var speed : int = 10;

function Update () {

var target: Vector3 = waypoints[current_waypoint].position;
var moveDirection : Vector3 = target - transform.position;

if(moveDirection.magnitude < 2)
{

current_waypoint++;

if(current_waypoint >= waypoints.length)

{
current_waypoint = 0;
}

}

else
{
rigidbody.velocity = moveDirection.normalized * speed;
}
transform.LookAt(waypoints[current_waypoint]);
}`

If all you want is to have the fish face the correct direction you could make a new GameObject that will be the root, add your current fish gameobject as a child to that root GameObject and move the fish component to the root instead. Now you can rotate the Fish GameObject to face the correct direction while the Fish component moves the root itself.

If you still want to use an animation, just do the exact same thing as above, but have the animation play on the Fish GameObject while the Fish Component moves the Root. This way the animation does not overwrite the transform changes you do in the Fish script.