void PlayerStartedJumping() { isOnPlatform = false; hasCrossedPlatform = false; PlayerJumped?.Invoke(); }
void FixedUpdate() { if (FreezeTime.i.timeFroze) { return; } if (tutorialFreeze) { return; } float horizontalInput = Input.GetAxis("Horizontal"); if (horizontalInput != 0 && !tutorialMoved) { tutorialMoved = true; StartCoroutine(TutorialMoved()); } rb.velocity = new Vector2(horizontalInput * movementSpeed, rb.velocity.y); if (Input.GetKey(KeyCode.Space) && isGrounded && !tutorialJumpFreeze) { if (!tutorialJumped) { tutorialJumped = true; PlayerMoved?.Invoke(); } isGrounded = false; rb.velocity = new Vector2(rb.velocity.x, Time.deltaTime * JumpSpeed); PlayerJumped?.Invoke(); } }
void FixedUpdate() { if (transform.position.y < -50f) { rb.velocity *= 0; rb.MovePosition(new Vector3(2, -2, 2) * -1); } var movement = new Vector3(movementX, 0, movementY) * Speed; var torque = new Vector3(movementY, 0, -movementX) * Speed; if (this.didJump) { PlayerJumped?.Invoke(); this.didJump = false; } rb.AddForce(movement); rb.AddTorque(torque); }