void Update() { if (isHoldingJump && (controllerAI.collisions.below || controllerAI.collisions.left || controllerAI.collisions.right)) //if we've hit a surface we interrupt the current jump { isHoldingJump = false; jumpTimer = 0; } if (Input.GetButtonDown("SideDash")) { //currentDestination = playerObj.transform.position; //hasReachedDestination = false; //if(alertState == AlertState.Default) movementAI.moveSpeed = 6f; //else if(alertState == AlertState.Suspicious) movementAI.moveSpeed = 9f; //else if(alertState == AlertState.Alert) movementAI.moveSpeed = 13f; } if (Time.frameCount % 90 == 0) { currentDestination = playerObj.transform.position; } MoveTo(currentDestination); if (isHoldingJump) { jumpTimer += Time.deltaTime; if (jumpTimer >= jumpVirtualPressDuration) { jumpTimer = 0; isHoldingJump = false; movementAI.OnJumpInputUp(); } } if (hasBufferedJump) { bufferedJumpTimer += Time.deltaTime; if (bufferedJumpTimer >= jumpBufferDuration) { movementAI.OnJumpInputDown(); hasBufferedJump = false; bufferedJumpTimer = 0f; jumpVirtualPressDuration = 0.05f; isHoldingJump = true; } } if (noInputsAllowed) { noInputAllowedTimer += Time.deltaTime; if (noInputAllowedTimer >= noInputAllowedDuration) { noInputAllowedTimer = 0f; noInputsAllowed = false; } } movementAI.UpdateMovementAI(); }