// Update is called once per frame void Update() { if (!VillanController.isAnimation || !canMove || PauseMenu.GameIsPaused) { return; } //animator state variables animator.SetFloat("Speed", Mathf.Abs(moveInput)); animator.SetBool("Grounded", grounded); animator.SetBool("Falling", false); animator.SetBool("SpacePressed", spacePressed); animator.SetBool("DownScene", inDownScene); inDownScene = CameraControler.change; grounded = IsGrounded(); // physic change in level 3 if (inDownScene) { rigidBody.velocity = new Vector2(0, -4f); rigidBody.gravityScale = 0.0f; } // back to physic from other levels if (!inDownScene) { rigidBody.gravityScale = 2f; } //jump if (grounded && Input.GetButtonUp("Jump") && !inDownScene && !animator.GetCurrentAnimatorStateInfo(0).IsName("FarmerFall")) { audio.Jump(); rigidBody.velocity = Vector2.up * jumpForce; ScoreScript.jumpCount++; jumpForce = 3; } //falling control if (grounded && isFalling) { audio.Fall(); animator.SetBool("Falling", true); isFalling = false; ScoreScript.fallNumber++; } if (rigidBody.velocity.y < -20 && !inDownScene) { isFalling = true; } //player flipping if (moveInput > 0 && !isFacingRight) { Flip(); } else if (moveInput < 0 && isFacingRight) { Flip(); } }