Skip to content

Instantly share code, notes, and snippets.

@jquave
Created December 2, 2013 02:49
Show Gist options
  • Select an option

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

Select an option

Save jquave/7744260 to your computer and use it in GitHub Desktop.
// For animation
bool aDucking = false;
if(input.directionalPad.y<0) aDucking = true;
float runSprintTransitionDelay = 1.20f;
float aWalkSpeed=Mathf.Abs(rigidbody2D.velocity.x);
if(isGrounded) {
if(aWalkSpeed>0.1f) {
if(currentAnimation=="CrowRun" && (lastSwitchedAnimation+runSprintTransitionDelay)<Time.time) {
ChangeAnimation("CrowSprint");
}
if(currentAnimation=="CrowJumpForward" || currentAnimation=="CrowJumpForward_IntoSprint") {
// If the player continues holding forward while in CrowJumpForward, play CrowJumpForward_IntoSprint
ChangeAnimation("CrowJumpForward_IntoSprint");
}
else if(currentAnimation!="CrowSprint")
ChangeAnimation("CrowRun");
if(aDucking) ChangeAnimation("CrowDuck");
}
else {
if(currentAnimation=="CrowJumpForward" || currentAnimation=="CrowJumpForward_IntoIdle") {
//ChangeAnimation("CrowJumpForward_IntoIdle");
}
else if(currentAnimation=="CrowSprint" || currentAnimation=="CrowStop") {
//If the player stops pressing all keys while in CrowSprint, play CrowStop. (If in CrowRun, just go back to idle, they dont have enough momentum to slide.)
ChangeAnimation("CrowStop");
}
else ChangeAnimation("CrowIdle");
// When stopped
if(aDucking) ChangeAnimation("CrowDuck");
}
}
else {
if(currentAnimation=="CrowJumpForward" || currentAnimation=="CrowSprint")
ChangeAnimation("CrowJumpForward");
else
ChangeAnimation("CrowJumpUpward");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment