Hey guys. I am well aware of how to “pause” the game by freezing time using Time.timeScale, but would it be able to only apply that effect to specific objects?
I want one object to continue it’s script, animations, and movement while all of the othes stop in place, if that would be possible.
This isn’t very convenient, but one thing you could do is set Time.timeScale to a very small value and then multiply everything (for your unfrozen object only) that depends on time by the inverse of that value.
For example, set Time.timeScale to 0.0001, then multiply by 10000 everywhere your object’s scripts use Time.deltaTime, and multiply your object’s animation speed by 10000, and if your object has any particle effects on it then multiply many of their properties by 10000, and if it has a Rigidbody then do some horrible things to speed up the Rigidbody component until it feels like normal speed, and change it all back when you want time to go back to normal…
It sounds like a lot of error-prone work, and it can be (depending on how complex your object is), but I have personally used it successfully in the past. And the good part is that you only need to worry about making changes to the one object that you want to be unfrozen; all other objects in the game will be automatically taken care of by the low timeScale value and will properly resume when the timeScale is changed back to normal, as long as you are using Time.deltaTime correctly in their scripts instead of doing calculations that rely on a particular framerate.
Of course, with this method, the other objects aren’t quite completely frozen, but you can set timeScale low enough that the player will not be able to tell the difference, or you could set timeScale high enough that the player can see a little slow-motion and call it a feature.
I know this post is two years old, but I just wanted to add that you CAN technically stop time for specific objects, because Time.timeScale only affects things operating under FixedUpdate (as a whole). So if you have an object you want to be able to move around when something is paused you can simply put anything you want to be pauseable in FixedUpdate and your non-pauseable objects in Update. Its not the most elegant solution, but it works.