Created
December 2, 2013 02:49
-
-
Save jquave/7744260 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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