void PlayerInput() { if (cc.isGrounded) { if (currentChar == characterTags.wings) { jumpAgain = true; } else { jumpAgain = false; } physicsFlag = physicsStates.run; if (Input.GetAxis("Horizontal") == 0) { physicsFlag = physicsStates.idle; } } else { if (physicsFlag == physicsStates.fall) { Fall(); } } if (Input.GetButtonDown("Jump")) { if (cc.isGrounded) { Jump(1); } else if (jumpAgain) { Jump(0.65f); } print("Jump"); //Keyboard - Space //Controller - A } if (Input.GetButtonDown("Special")) { Special(); print("Special"); //Keyboard - Q or E //Controller - Right Trigger or Y } if (Input.GetButtonDown("Punch")) { Punch(); print("Punch"); //Keyboard - Left click //Controller - X } }
void PhysicsFlags() { switch (physicsFlag) { case physicsStates.idle: PlayAnimation("Idle", 1); running = false; break; case physicsStates.run: float animSpeed = Mathf.Abs(Input.GetAxis("Horizontal")); if (moveDirection.x > 0) { PlayAnimation("RunRight", animSpeed * 2); } else { PlayAnimation("RunLeft", animSpeed * 2); } break; case physicsStates.jump: if (ySpeed < 0) { physicsFlag = physicsStates.fall; } break; case physicsStates.punch: PlayAnimation("RightPunch", 1); break; case physicsStates.special: PlayAnimation("Idle", 1); break; case physicsStates.swap: PlayAnimation("Idle", 1); break; case physicsStates.death: PlayAnimation("Idle", 1); break; } }
void Jump(float jumpMultiplier) { if (moveDirection.x > 0) { PlayAnimation("RightJump", 1, .2f); } else if (moveDirection.x < 0) { PlayAnimation("LeftJump", 1, .2f); } else { PlayAnimation("Jump", 1, .2f); } ySpeed = jumpSpeed * jumpMultiplier; physicsFlag = physicsStates.jump; if (!cc.isGrounded) { jumpAgain = false; } }
void Swap() { physicsFlag = physicsStates.swap; }
void Special() { physicsFlag = physicsStates.special; }
void Punch() { physicsFlag = physicsStates.punch; }