Skip to content

Instantly share code, notes, and snippets.

@jquave
Created December 4, 2013 04:41
Show Gist options
  • Select an option

  • Save jquave/7782452 to your computer and use it in GitHub Desktop.

Select an option

Save jquave/7782452 to your computer and use it in GitHub Desktop.
switch (currentAnimation) {
// Runs
case "CrowRun":
if(player.jumping)
ChangeAnimation("CrowJumpForward");
else if(player.sliding)
ChangeAnimation("CrowStop");
else if(atMaxSpeed) {
// Player is at max speed, switch to sprint after 1 second
if(Time.time>(lastSwitchedAnimation+runToSprintTime))
ChangeAnimation("CrowSprint");
}
else if (walkSpeed<0.1f)
ChangeAnimation("CrowIdle");
break;
case "CrowSprint":
if(player.jumping)
ChangeAnimation("CrowJumpForward");
else if(player.sliding)
ChangeAnimation("CrowStop");
else if(!atMaxSpeed && walkSpeed>0.1f)
ChangeAnimation("CrowRun");
else if (walkSpeed<0.1f)
ChangeAnimation("CrowIdle");
break;
// Jumps
case "CrowJumpUpward":
if(player.isGrounded && ((lastSwitchedAnimation+0.21f)<Time.time)) // Wait 0.21 seconds before trying to land, otherwise he lands immediately
ChangeAnimation("CrowJumpup_Land");
else if(player.isGrounded && animDone)
ChangeAnimation("CrowIdle");
break;
case "CrowJumpForward":
case "CrowJumpForward_IntoIdle":
if(player.isGrounded && ((lastSwitchedAnimation+0.21f)<Time.time)) { // Wait 0.21 seconds before trying to land, otherwise he lands immediately
if(atMaxSpeed)
ChangeAnimation("CrowJumpForward_IntoSprint");
else
ChangeAnimation("CrowStop");
}
else if(player.isGrounded && animDone)
ChangeAnimation("CrowIdle");
break;
case "CrowJumpForward_IntoSprint":
if(player.jumping)
ChangeAnimation("CrowJumpUpward");
else if(player.sliding)
ChangeAnimation("CrowStop");
else if(animDone && atMaxSpeed)
ChangeAnimation("CrowSprint");
else if(animDone && walkSpeed>0.1f)
ChangeAnimation("CrowRun");
else if(animDone)
ChangeAnimation("CrowStop");
break;
// Other
case "CrowStop":
if(player.jumping)
ChangeAnimation("CrowJumpBack");
else if (animDone)
ChangeAnimation("CrowIdle");
break;
case "CrowIdle":
if(player.jumping)
ChangeAnimation("CrowJumpUpward");
else if(walkSpeed>0.3f)
ChangeAnimation("CrowRun");
break;
case "CrowJumpup_Land":
if(player.jumping)
ChangeAnimation("CrowJumpUpward");
else if(player.sliding)
ChangeAnimation("CrowStop");
else if (animDone)
ChangeAnimation("CrowIdle");
break;
case "CrowDuck":
if(player.jumping)
ChangeAnimation("CrowJumpUpward");
else if(isDucking)
break;
else if (animDone)
ChangeAnimation("CrowIdle");
break;
default:
ChangeAnimation("CrowIdle");
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment