Need help with a performance issue on my animation script

Hi

I just wanted to know if anyone can find the flaw in my animation script.
The script is really not very long and not much is going on, but still I lose around 100 FPS when it is active

var movingAnim : boolean = false;

function Update()
{
	Idle();
	if (Input.GetButtonDown("Forward"))
	{
		movingAnim = true;
	}
	if (Input.GetButtonUp("Forward"))
	{
		movingAnim = false;
	}
	if (movingAnim)
	{
		Move();
	}
	else if (movingAnim == false)
	{
		MoveToIdle();
	}
}

function Idle()
{
	animation.Blend("idle8-motion");
	animation.Blend("flap");
}

function Move()
{
	animation.Blend("8-motion");
	animation.Blend("flap");
}

function MoveToIdle()
{
	animation.Blend("8-motion",0,0.3);
	animation.Blend("idle8-motion");
	animation.Blend("flap");
}

I would really appreciate the help

thanks in advance

Your script should look something more like this:

function Start()
{
	Idle();
}

function Update()
{
    if (Input.GetButtonDown("Forward"))
    {
       Move();
    }
    if (Input.GetButtonUp("Forward"))
    {
       MoveToIdle();
    }
}

function Idle()
{
    animation.Blend("idle8-motion");
    animation.Blend("flap");
}

function Move()
{
    animation.Blend("8-motion");
    animation.Blend("flap");
}

function MoveToIdle()
{
    animation.Blend("8-motion",0,0.3);
    animation.Blend("idle8-motion");
    animation.Blend("flap");
}

You don’t even need the variable movingAnim as far as I know, the main idea is you only need to start an animation instead of calling the start of that animation multiple times.

Please let me know if this script works for you.

Cheers