public void CheckOutOfBounds() { if (worldFloorLimit.IsTouching(playerCollider)) { loader.FadeToLevel(loader.ReturnCurrentSceneIndex()); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.E)) { if (!isGrabbing) { OnCrateCollision(); } else { ThrowCrate(grabbedCrate); } } if (isGrabbing) { PickCrate(grabbedCrate); } movement.x = Input.GetAxis("Horizontal"); transform.position += movement * Time.deltaTime * maxSpeed.x; animator.SetBool("isRunning", false); animator.SetBool("isFalling", false); animator.SetBool("isJumping", false); running = false; if (Input.GetAxis("Horizontal") > 0) { animator.SetBool("isRunning", true); running = true; transform.localRotation = Quaternion.Euler(0, 180, 0); flipped = false; //Debug.Log("Running"); } if (Input.GetAxis("Horizontal") < 0) { animator.SetBool("isRunning", true); running = true; transform.localRotation = Quaternion.Euler(0, 0, 0); flipped = true; //Debug.Log("Running"); } feetOffset.y = -2 * transform.localScale.y; isGrounded = Physics2D.OverlapCircle(transform.position + feetOffset, checkRadious, whatIsGround); if (running && !isGrounded) { animator.SetBool("isRunning", false); running = false; } if (dead) { animator.SetBool("isDying", true); animator.SetBool("isEmpty", true); Level_script.FadeToOwnLevel(); } if (isGrounded) { falling = false; jumping = false; animator.SetBool("isJumping", false); animator.SetBool("isFalling", false); } else { running = false; if (rb.velocity.y > 0) { animator.SetBool("isJumping", true); animator.SetBool("isFalling", false); // Debug.Log("Jumping!"); jumping = true; falling = false; } else { animator.SetBool("isFalling", true); animator.SetBool("isJumping", false); // Debug.Log("Falling!"); falling = true; jumping = false; } } if (isGrounded && Input.GetButtonDown("Jump")) { rb.velocity = Vector2.up * jumpForce; } if (startTimer) { timer += Time.deltaTime; if (timer >= 15.0f) { playFx = true; animator.SetBool("isDying", true); Level_script.FadeToLevel(0); } } }