To implement slow motion, follow these steps:
- Import the BallGame package into your project and, from the Project panel, open the level named scene1_ballGame.
- Create a C# script class called BulletTime, and add an instance object as a component to the First Person Controller GameObject:
using UnityEngine; using UnityEngine.UI; using System.Collections; public class BulletTime : MonoBehaviour { public float slowSpeed = 0.1f; public float totalTime = 10f; public float recoveryRate = 0.5f; public Slider EnergyBar; private float elapsed = 0f; private bool isSlow = false; void Update (){ if (Input.GetButtonDown ("Fire2") && elapsed < totalTime) SetSpeed (slowSpeed);
if (Input.GetButtonUp ("Fire2")) SetSpeed (1f); if ...