// Update is called once per frame void Update() { if (states.current == PlayerStates.AnimStates.stun) { stunned = true; if (Input.GetKeyDown(KeyCode.Space)) { stunnedCounter++; } if (stunnedCounter == 3) { print("Free"); stunned = false; stunnedCounter = 0; states.SetStateToIdle(); } } if (!stunned) { if (jump) { jumpIndex++; } if (states.current != PlayerStates.AnimStates.stun && states.current != PlayerStates.AnimStates.death) { if (Input.GetKeyDown(KeyCode.A)) { if (justFinished && direction > 0) { currentSpeed = 0; justFinished = false; } //Debug.Log("Left"); direction = -1; //currentSpeed += direction * (accelerationRate * Time.fixedDeltaTime); //Player.Instance.spriteR.flipX = true; if (onGround) { states.current = states.current == PlayerStates.AnimStates.atk ? PlayerStates.AnimStates.runatk : PlayerStates.AnimStates.run; if (Input.GetKeyDown(KeyCode.LeftShift)) { StartCoroutine(dodgeRollMove()); } } } if (Input.GetKeyDown(KeyCode.D)) { if (justFinished && direction < 0) { currentSpeed = 0; justFinished = false; } //Debug.Log("Right"); direction = 1; //currentSpeed += direction * (accelerationRate * Time.fixedDeltaTime); //Player.Instance.spriteR.flipX = false; if (onGround) { states.current = states.current == PlayerStates.AnimStates.atk ? PlayerStates.AnimStates.runatk : PlayerStates.AnimStates.run; if (Input.GetKeyDown(KeyCode.LeftShift)) { StartCoroutine(dodgeRollMove()); } } //Emily you might need to keep in mind that I'm about to add a dodge roll } if (Input.GetKeyUp(KeyCode.A)) { if (Input.GetKey(KeyCode.D)) { direction = 1; if (onGround) { StartCoroutine(dodgeRollMove()); } } else { direction = 0; if (onGround && states.current != PlayerStates.AnimStates.atk && states.current != PlayerStates.AnimStates.runatk) { states.current = PlayerStates.AnimStates.idle; } } } if (Input.GetKeyUp(KeyCode.D)) { if (Input.GetKey(KeyCode.A)) { direction = -1; if (onGround) { StartCoroutine(dodgeRollMove()); } } else { direction = 0; if (onGround && states.current != PlayerStates.AnimStates.atk && states.current != PlayerStates.AnimStates.runatk) { states.current = PlayerStates.AnimStates.idle; } } } if (Input.GetKeyDown(KeyCode.Space) && !inDodgeRoll) { //Debug.Log("Jumped"); jump = true; if (jumpIndex == 0) { ani.SetBool("isJumping", true); firstJump = true; } } } else { direction = 0; } ani.SetFloat("AirSpeed", rb.velocity.y); } }