- Home /
Is there a local Time.timeScale?
I just found Time.timeScale and I noticed that it affects the whole game. Though, is there a local Time.timeScale (or likewise) for a specific object? Like if I have a time-device that slows the time for all objects within a certian sphere, but not those outside?
Thanks in advance :)
BTW my question is not "How to pause the game", I am just curious if timeScale is the easiest way to slow down time (NOT entierly stop it, slow it down!) for specific objects
1) There definitely is not
2) As a rule, there is very very little reason to use timeScale. You could go so far as to say "never ever use it." You should explain what you are trying to achieve.
3) For timers in Unity you use Invoke() or InvokeRepeating(). Pls search on here for millions of great examples about it.
@Fattie: timeScale is useful in some circumstances, for example, pausing the game (though you do need to be careful with it).
I'd recommend having a time$$anonymous$$ultiplier variable in each object you want to control individually, then, for any movement you do, multiply it by this value. This will allow you to slow down motion by setting it to a value less than 1, or speed it up by setting it to a value greater than 1.
lol dude I've been explaining timeScale to people on here for some three years ;-)
BTW mutual there are various assets on the asset store you should check out, relating to pausing gameplay. I have not tried any but for example http://forum.unity3d.com/threads/136139-Pause-Controller-Released-Group-Pausing-without-timeScale-0
pausing gameplay is always a huge problem. be aware that "setting the time scale to zero" (in "all of unity") is kind of a quick fix. We're all guilty of it at times but it's not like at nintendo they go oh set the timescale to zero to pause.
Really every single thing in the game (I mean enemies, clouds, whatever) should have a "game pause" concept and you signal them all to pause. generally the whole business of pausing games is a huge nuisance. inevitably in any game you have zillions of timers and what have you in progress and they all have slightly different paradigms of how they should be treated for a "game pause". of course you can't pause - notably - the button that allows you to unpause :) the whole thing is a pain in the ass
What most games do during pause is prevent game-changing motion (characters moving, attack animations, etc.), but ignore the rest of the scene. They then take a screenshot of the scene, and draw that over the screen ins$$anonymous$$d of rendering anything - this gives the illusion of proper pausing, while not having to bother with fine details.
Having said that, actually stopping the update loop (which is essentially what setting timeScale to 0 does) is a perfectly valid way of pausing a game, and a lot of games do use it. They do, however, often run a second update loop (or have a conditional that runs either one loop or the other depending on pause state), unrelated to the main game's loop, to handle the pause menu.
Answer by meat5000 · Oct 08, 2013 at 09:27 AM
You can easily make your own Timer by making a variable a function of time. Use that in a script instead of Time.time and you can scale it how you please :)
e.g If you have
timer += Time.deltaTime and only call it every other frame you are getting a half timescale. Or just add a multiplier.
Your answer
Follow this Question
Related Questions
Bullet slowing down while snapping to sphere normals 0 Answers
getting the direction of object 1 Answer
Emmiter in time intervals 1 Answer
swapping out an object on collision 2 Answers
Problem with Object collision 1 Answer