Play jump animation whilst run animation is playing using Loop Time

Hi guys,

So I’ve made a non humanoid 3D character - starting off with a simple run loop and jump animation.

So I’ve setup the animator as Entry > run then jump is in there, so I can refer to it in the script

Run is setup frame 0-20 with Loop Time ticked.
Jump is setup frame 20-40 without Loop Time ticked.

Below is my amateur code :confused: got to start somewhere!

#pragma strict

var anim : Animator;

function Start() {
	anim = GetComponent.<Animator>();
}


function Update () {

	transform.Translate(Vector3.forward * Time.deltaTime * 10);
	
	if(Input.GetKeyDown(KeyCode.Space)){
    	anim.Play("jump");
    	transform.Translate(Vector3.up * Time.deltaTime * 10);
    } else {
        anim.Play("run");
    }
         
}

So the problem is the run animation is playing on a loop (woohoo), which is fine, but when I hit the space bar to make the character jump it only plays the jump animation for a split second before returning to the run animation. Anyway to play the jump animation till the end before returning to the run loop?

Many Thanks

Answering for prosperity

The if statement checks when the space bar is down and plays the jump animation, else it plays the run animation

So as soon as you release the space bar it will start playing the ‘Run’ animation again interrupting the ‘Jump’ animation

Look at using trigger’s and/or booleans within the Animator screen to control switching between animations