// Update is called once per frame void Update() { if (!playerRespawn.IsAlive() && !respawnLock) { respawnLock = true; Invoke("RespawnFrog", 1f); } }
void Update() { horizontalMove = Input.GetAxisRaw("Horizontal") * moveSpeed; jumpForce = JumpCalc(); alive = respawn.IsAlive(); if (alive) //if player is alive do stuff { //animations if (crouch == false && controller.isGrounded()) //not crouch or and on ground { if (Input.GetButtonDown("Jump") && controller.isGrounded()) //change to jump animation { jumpSound[1].Play(); // uses second audio source component in player jump = true; ChangeAnimationState(PLAYER_JUMP); hasJumped = true; Invoke("ChangeJumpState", 0.1f); } if (!hasJumped) //if not jump, do idle or run { if (horizontalMove == 0 && controller.isGrounded()) { ChangeAnimationState(PLAYER_IDLE); } else if (horizontalMove != 0 && controller.isGrounded()) { ChangeAnimationState(PLAYER_RUN); } } } if (Input.GetButtonDown("Crouch") && controller.isGrounded()) //if crouch { crouch = true; ChangeAnimationState(PLAYER_CROUCH); } else if (Input.GetButtonUp("Crouch") && controller.canStand()) //if player can stand change idle { crouch = false; ChangeAnimationState(PLAYER_IDLE); } if (!Input.GetButton("Crouch") && controller.canStand()) //player moves to where they can stand, change to idle { crouch = false; // ChangeAnimationState(PLAYER_IDLE); } } else //not alive { ChangeAnimationState(PLAYER_HURT); } }