// Update is called once per frame void FixedUpdate() { currentVel = playerRigidBody.velocity; if (player.PState == PlayerState.KnockedBack) { CurrentSpeed = 0; StartCoroutine("KnockBack", vel); if (knockToLeft) { vel = new Vector2(Mathf.Abs(vel.x) * -1, vel.y); if (vel.x <= 0) { vel = new Vector2(vel.x + (knockBackVelocity.x / 15), vel.y); } } else { if (vel.x >= 0) { vel = new Vector2(vel.x - (knockBackVelocity.x / 15), vel.y); } } if (vel.y >= -8) { vel = new Vector2(vel.x, vel.y - (knockBackVelocity.y / 5)); } } else { if (jumpBtn.buttonDown) { brake = false; if (player.PState == PlayerState.OnGround) { Act(InputCode.Jump); sfxHandler.playSFX = 1; } } if (!jumpBtn.buttonDown) { sfxHandler.playSFX = 0; } bj.gettingJumpInput(jumpBtn.buttonDown); if (/*imap.getKey (InputCode.MoveRight) */ vJoystick.MovetoRight() && vJoystick.Moving()) { Act(InputCode.MoveRight); player.flip = false; if (player.PState == PlayerState.OnGround) { sfxHandler.playSFX = 2; } brake = false; } if (/*imap.getKeyUp(InputCode.MoveRight)*/ !vJoystick.Moving()) { sfxHandler.playSFX = 0; } if (/*imap.getKeyUp(InputCode.MoveLeft)*/ !vJoystick.Moving()) { sfxHandler.playSFX = 0; } if (/*imap.getKey (InputCode.MoveLeft) */ !vJoystick.MovetoRight() && vJoystick.Moving()) { Act(InputCode.MoveLeft); player.flip = true; if (player.PState == PlayerState.OnGround) { sfxHandler.playSFX = 2; } brake = false; } brake = true; } if (brake) { playerRigidBody.velocity = new Vector2(friction * playerRigidBody.velocity.x, playerRigidBody.velocity.y); //playerRigidBody.velocity *= friction; playerRigidBody.angularVelocity *= friction; } }