void FixedUpdate() { bool touchingGround = checkGround.OnGround(colliderBox); if (Input.GetKeyDown(KeyCode.S)) { if (touchingGround && !inRoll) { startTime = Time.time; anim.SetBool("roll", true); anim.SetBool("run", false); inRoll = true; colliderBox.size = new Vector2(colliderBox.size.x, colliderBox.size.y / 2); print(rb.velocity); rollPusher.force = new Vector2(dirCheck.getDirection() * rollSpeedX, 0); } } else if (inRoll && Time.time - startTime > rollDuration) { inRoll = false; print("roll should have ended"); colliderBox.size = new Vector2(colliderBox.size.x, colliderBox.size.y * 2); rollPusher.force = new Vector2(0, 0); rb.velocity = new Vector2(0, rb.velocity.y); anim.SetBool("roll", false); } }
// Update is called once per frame void FixedUpdate() { if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.A)) { if (!anim.GetBool("roll")) { rb.velocity = new Vector2(dirCheck.getDirection() * moveSpeedX, rb.velocity.y); } if (!anim.GetBool("roll") && !anim.GetBool("jump")) { anim.SetBool("run", true); } } else { anim.SetBool("run", false); } }