Reputation: 58
I want to use TrailRenderer when my game is paused, but since timeScale is 0 the resulting deltaTime is 0. This caused TrailRenderer to not function (the tail never dies).
I didn't find any parameter to be able to manually set the update duration or call update of TrailRenderer.
Like in an Animator we have the option to make it update in "UnscaledDeltaTime", how can i do it for a TrailRenderer?
Upvotes: 1
Views: 1047
Reputation: 1074
There's a value for Time.unscaledDeltaTime
that you could use.
There is a post on the Unity forums describing a similar peculiarity with Time.unscaledTime
and Time.realtimeSinceStartup
. The OP states what they're using at the bottom of the post:
float lastFrameRealtimeSinceStartup;
float unscaledTimeWhilePlaying;
void Update() {
float dRealtime = Time.realtimeSinceStartup - lastFrameRealtimeSinceStartup;
if (dRealtime > (1.0f / 20.0f)) {
//Assume the high dTime is due to the game being paused or lost focus
dRealtime = 1.0f / 20.0f; //Set it to a reasonable time (20 FPS)
}
unscaledTimeWhilePlaying += dRealtime;
lastFrameRealtimeSinceStartup = Time.realtimeSinceStartup;
}
Upvotes: 1
Reputation: 518
After a little bit of research, it doesn't seem like you can do this. You can do a few things here, but none of it will be as easy as just setting the time scale on the renderer.
Maybe think about how you are pausing the game and see if the timeScale really is your best solution.
This question came up here as well How to make TrailRenderer work when timeScale is 0 in Unity?.
This seems to indicate that it cannot be done.
Upvotes: 1