You need to implement a "bullet time" (slow-motion) mechanic for a scene with falling spheres.
- Scene: 3 spheres (Sphere) with a
Rigidbodycomponent, falling from a height of 10 meters onto a plane (Plane) with a collider. - Script for each sphere: When a sphere hits the plane, it should be destroyed (
Destroy(gameObject)) and increase a score counter by +1. - Controls:
- Press
Q— slow down time to0.2(bullet time). - Press
E— return to normal speed (1.0). - Press
Space— pause/resume.
- Press
- Correct physics behavior: When slowing down or speeding up, the physics (falling spheres) should slow down/speed up proportionally.
Use the correct methods (
UpdatevsFixedUpdate) andTime.deltaTime/Time.fixedDeltaTime. - UI (optional): On-screen text showing:
- Current
Time.timeScale(rounded to 1 decimal) - Current score
- Current
Learn to properly use Time.deltaTime for movement (if spheres were moved manually),
Time.timeScale to control global time, and understand how Time.fixedDeltaTime automatically adjusts to time scale for correct physics.
- Create a
TimeManager.csscript (on an empty GameObject) to handle input and display UI. - Create a
DestroyOnCollision.csscript for spheres that destroys the sphere and increases the score upon collision with the plane (using a static variable or a reference to TimeManager). - Ensure that sphere movement (gravity) correctly reacts to
Time.timeScale— thanks toFixedUpdate, no extra work is needed. - Add text (UI Text or TextMeshPro) to display
Time.timeScaleand the score.
- Pressing
Qslows down the falling spheres; pressingEreturns to normal. - Pressing
Spacefreezes everything, but the UI (score and text) may continue updating (if you useunscaledDeltaTime— optional). - Physics remains stable (spheres do not fall through the floor).
- Score increases each time a sphere is destroyed.