Animation Problem - When I crossfade back from running

Ok basically It cross fades between walking and running etc whenever the player presses boost or not etc.

The game starts fine, the idle animation plays; I then start walking it works fine, start running again fine… The problem then comes when I stop boosting/running and return to walking - it kind of has the animation however the characters feet are animated wrong - there at a different rotation to what they should be, any help would be appreciated.

Below is the code:

var landBounceTime = 0.6;

var runSpeedScale = 1.0;
var walkSpeedScale = 1.0;
var lookSpeedScale = 0.5;
var idleSpeedScale = 0.7;


private var lastJump : AnimationState;
var idleTimer = 0;
function Start ()
{
	// We are in full control here - don't let any other animations play when we start
	animation.Stop();

	// By default loop all animations
	animation.wrapMode = WrapMode.Loop;

	// The jump animation is clamped and overrides all others
	var jump = animation["jump"];
	jump.layer = 1;
	jump.enabled = true;
	jump.wrapMode = WrapMode.Clamp;
	
	
		StartTimer();
}

function StartTimer(){
	idleTimer += 1;
	yield new WaitForSeconds (1);
	StartTimerLoop();
}

function StartTimerLoop(){
	StartTimer();
}

function DoIdle2(){
	animation.CrossFade("idle2");
	yield new WaitForSeconds (1.5);
	animation.CrossFade("idle");
}

function DoIdle3(){
	animation.CrossFade("idle3");
	yield new WaitForSeconds (2.5);
	animation.CrossFade("idle");
	idleTimer = 0;
}

function Update ()
{

	
	var marioController : ThirdPersonController = GetComponent(ThirdPersonController);
	var currentSpeed = marioController.GetSpeed();
	

	if (currentSpeed > 0.2){
		idleTimer = 0;
	}

	else if (currentSpeed > 0.2  !Input.GetButton ("Fire3")  !TractorBeamScript.isInTractorBeam)
		animation.CrossFade("walk");
	// Switch between idle and walk
	if (TractorBeamScript.isInTractorBeam)
		animation.CrossFade("tractorbeam");
	else if (currentSpeed > 0.2  !Input.GetButton ("Fire3"))
		animation.CrossFade("walk", 0.01);
	else if (currentSpeed > marioController.walkSpeed  Input.GetButton ("Fire3"))
		animation.CrossFade("run" ,0.1);
	else if (currentSpeed > 0.2  currentSpeed <= marioController.walkSpeed)
		animation.CrossFade("walk", 0.01);
	else if (idleTimer < 5  currentSpeed < 0.2)
		animation.CrossFade("idle");
	else if (idleTimer > 5  idleTimer < 14  currentSpeed < 0.2){
		DoIdle2();
	}
	else if(idleTimer > 14  currentSpeed < 0.2){
		DoIdle3();
	}
//		else if (currentSpeed > 0.2  !Input.GetButton ("Fire3"))
//		animation.CrossFade("walk");
		

	// When we jump we want the character start animate the landing bounce, exactly when he lands. So we do this:
	// - pause animation (setting speed to 0) when we are jumping and the animation time is at the landBounceTime
	// - When we land we set the speed back to 1
	if (marioController.IsJumping())
	{
		if (lastJump.time > landBounceTime)
			lastJump.speed = 0;
	}
	
	animation["idle"].normalizedSpeed = idleSpeedScale;
	animation["idle2"].normalizedSpeed = lookSpeedScale;
	animation["run"].normalizedSpeed = runSpeedScale;
	animation["walk"].normalizedSpeed = walkSpeedScale;

}

function DidJump () {
	// We want to play the jump animation queued,
	// so that we can play the jump animation multiple times, overlaying each other
	// We dont want to rewind the same animation to avoid sudden jerks!
	lastJump = animation.CrossFadeQueued("jump", 0.3, QueueMode.PlayNow);
	
}

function DidLand () {
	lastJump.speed = 1;
}

[/code]

Anyone? Please?

It’s kind of urgent :S.

Adam.

Did you try to use the synclayer feature ?
Doc says :
"
When blending between two looping animations they often have different lengths. For example a walk cycle often takes longer than a run cycle. When blending between them you need to make sure that the foot placement of the walk and run cycle happens at the same time. In other word playback speed of the animations must be adjusted so that the animations are synchronized. SyncLayer will calculate the average normalized playback speed of all animations in the layer based on their blend weight. Then it will apply that playback speed to all animations in the layer.

// Puts the walk and run animation in the same
// layer and synchronizes their speed
animation[“walk”].layer = 1;
animation[“run”].layer = 1;
animation.SyncLayer(1);

"