Slow time for everyone but Player

I just finished the Time.timeScale() lesson, and it hit close to an idea I’ve had for a long time for a platformer I’ve been wanting to build. One of the mechanics I want for it would be the ability for the player to slow time for a moment, for everyone but the player. Like, imagine a bunch of enemies with guns or something all coming at you and the only way to get past them is to slow time for a few relative seconds so you can either defeat or get past the enemies. I understand how I might use the gameSpeed thing to slow down certain moments of the entire game, but how do you think I could do that for everyone EXCEPT the player?

Hi Emmet,

The first idea popping up in my mind is to multiply a value with the speed of the player according to the time scale. For instance, if you set the Time.timeScale value to 0.5f, you multiply everything involving the player’s movement with 2f.

Or rather:

player stuff * (1 / Time.timeScale)

I did not test this, so I do not know if this will work.

I was thinking the other way as well, you could multiply all enemy stuff my a factor as well, like .5 on the time

Yes, that’s also possible. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms