x


Stop Time for Specific Objects?

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.

more ▼

asked Mar 01 '12 at 12:46 AM

Xatoku gravatar image

Xatoku
152 73 81 88

I would also like to know this. Any updates?

Jan 27 at 10:16 AM Hamesh81
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Mar 01 '12 at 06:22 AM

jspease gravatar image

jspease
569 1 3 6

(comments are locked)
10|3000 characters needed characters left

From what I understand, that's one of the stuff people hope to get in unity 4.0

more ▼

answered Mar 01 '12 at 02:38 AM

Berenger gravatar image

Berenger
11k 12 19 53

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1095
x573
x262
x177
x22

asked: Mar 01 '12 at 12:46 AM

Seen: 1356 times

Last Updated: Jan 27 at 10:16 AM