Example #1
0
    void Update()
    {
        if (Input.GetKeyUp(kinematicActivateKey))
        {
            isKinematic = !isKinematic;

            setImages(isKinematic);

            if (postProcessManager != null)
            {
                if (isKinematic)
                {
                    postProcessManager.ChangeVolume(Mode.kinematic);
                }
                else
                {
                    postProcessManager.ChangeVolume(Mode.nonKinematic);
                }
            }

            if (audioController != null)
            {
                if (isKinematic)
                {
                    audioController.LowpassAudio();
                }
                else
                {
                    audioController.RemoveLowpassEffect();
                }
            }

            ActivateGravity(isKinematic);
        }
    }
Example #2
0
    void Update()
    {
        //Check to see if time change key has been released
        if (Input.GetKeyUp(timeScaleKey))
        {
            //Reverse the time toggle and change the timeScale
            timeToggle          = !timeToggle;
            Time.timeScale      = timeToggle ? timeScale : defaultTimeScale;
            Time.fixedDeltaTime = defaultFixedDeltaTime * Time.timeScale;

            //Update the UI
            setTimeImage(timeToggle);

            //Check if postProcessManager is set in Inspector
            if (postProcessManager != null)
            {
                //If time has been slowed, activate the postProcessVolume to change the post-effects
                if (timeToggle)
                {
                    postProcessManager.ChangeVolume(Mode.timescale);
                }
                else
                {
                    postProcessManager.ChangeVolume(Mode.defaultTimeScale);
                }
            }

            //Check if Audiocontroller is assigned in Inspector
            if (audioController != null)
            {
                //If time has been slowed lower the pitch on the audio, otherwise set it to full pitch/speed
                if (timeToggle)
                {
                    audioController.HalfPitchAudio();
                }
                else
                {
                    audioController.FullSpeedAudio();
                }
            }
        }

        //Check to see if the gravity key has been pressed and released
        if (Input.GetKeyUp(gravityKey))
        {
            //Flip the toggle and update the gravity value
            gravityToggle   = !gravityToggle;
            Physics.gravity = gravityToggle ? fakeGravity : defaultGravity;
            setGravityImages(gravityToggle);

            //Check if postProcessManager is set in Inspector
            if (postProcessManager != null)
            {
                //If gravity has been changed, activate the postProcessVolume to change the post-effects

                if (gravityToggle)
                {
                    postProcessManager.ChangeVolume(Mode.customGravity);
                }
                else
                {
                    postProcessManager.ChangeVolume(Mode.standardGravity);
                }
            }

            if (audioController != null)
            {
                //If gravity has been reversed fade in the reversed audio, otherwise fade in the forward audio
                if (gravityToggle)
                {
                    audioController.AudioReverse();
                }
                else
                {
                    audioController.AudioForward();
                }
            }
        }
    }