- Home /
C# Slow Down all Gameobjects Within another Gameobject's Collider
Do Gameobjects have their own equivalent of Time.time? I could only find the global float of Time.time and not a singular gameobject's Time.time. I'm trying to slow down all gameobjects within another gameobject's collider and not slow down my game entirely. I have got some pseudocode of what I'm trying to create. Any help would be appreciated.
void OnTriggerEnter2D(Collider2D other)
{
other.time.time = time.time/2f;
}
The easiest solution would probably be to simply add a float value to the classes you want to slow down which you can use to control the time scale. Everywhere you use time, change it to time*timeScale. Then, whenever your object collides with the slow area, change the timeScale value to whatever fraction you're looking for.
Answer by allenallenallen · Dec 23, 2015 at 04:35 AM
There isn't a built-in local timer but you can easily make one.
Similar questions: http://answers.unity3d.com/questions/551176/is-there-a-local-timetimescale.html
Answer by G4merSylver · Dec 23, 2015 at 01:24 PM
If its a rigidbody moving via forces that you want to slow down just increase the drag. Else if you move via transform you could try adding the speedModifier that when staying inside the trigger would be reduced to e.G 0.5 and when leaving the trigger would return to 1.0