Exemplo n.º 1
0
    private void Update()
    {
        if (raycastAimPlaneTransform != null)
        {
            raycastAimPlaneTransform.position = transform.position + initialRaycastAimPlanePosOffset;
        }

        if (!waitingForFallToGroundCheck)
        {
            CheckForGround();
        }
        else
        {
            if (rb.velocity.y < 0.0f)
            {
                waitingForFallToGroundCheck = false;
                isJumping = false;
            }
        }

        if (isGrounded)
        {
            if (!rollingAudioSource.FadeOutIsActive())
            {
                float volumeInterpValue = Mathf.Clamp(
                    rb.velocity.magnitude / maxSpeedForRollVolume,
                    0.0f, 1.0f);
                rollingAudioSource.volume = Mathf.Lerp(0.0f, 0.3f, volumeInterpValue);

                if (!rollingAudioSource.isPlaying)
                {
                    rollingAudioSource.Play();
                }
            }
        }
        else
        {
            if (rollingAudioSource.isPlaying && !rollingAudioSource.FadeOutIsActive())
            {
                rollingAudioSource.FadeOut();
            }
        }

        /*if (inputIsEnabled) {
         *              if (isGrounded) {
         *                      if (Input.GetButtonDown("Jump")) {
         *                              GeneralAudioPool.Instance.PlaySound(jumpAudioClip, 0.25f, Random.Range(0.9f, 1.1f));
         *
         *                              rb.AddForce(Vector3.up * initialJumpLaunchForce, ForceMode.Impulse);
         *                              waitingForFallToGroundCheck = true;
         *                              isGrounded = false;
         *
         *                              jumpActiveTimer = 0.0f;
         *                              isJumping = true;
         *                      }
         *              }
         *              if (Input.GetButtonUp("Jump")) {
         *                      isJumping = false;
         *              }
         *      }*/

        if (transform.position.y < yPosResetCutoff)
        {
            transform.position = initialPos;
            rb.velocity        = Vector3.zero;
            rb.angularVelocity = Vector3.zero;
        }

        if (Application.isEditor && !sceneIsLoading && Input.GetKeyDown(KeyCode.BackQuote))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            sceneIsLoading = true;
        }
    }