- Home /
Pausing a Mathf.Lerp
Hello,
Is it possible to pause a Mathf.Lerp method? (same for Vector3.Lerp and .Slerp stuff)
I mean pausing it, not stopping it using a break statement.
The practical effect of this is being able to pause a game while a Lerp is running and keep the Lerp going after resuming the game.
This doesn't allow me to click on buttons while the game is paused.
However, I can't move/show/hide menus in pause mode with TimeScale = 0
The answer below is what I was looking for, thank you all :)
Answer by benni05 · May 06, 2014 at 11:21 AM
The Lerp methods expect a float value that determines the actual interpolated "position" value between the "from" and "to" value. If you stop increasing/decreasing that value you in effect "pause" the Lerp function. It will then always return the same value until you start increasing/decreasing it again.
If the Lerp is running in a coroutine (you know, in a while(t<1) thing), would it affect the performance to keep the interation running in there?
EDIT: Tested, worked like a charm. It seems to not affect the performance. Thanks!
Your answer
Follow this Question
Related Questions
how to pause and resume music after pausing game? 4 Answers
How can i pause gradually from timeScale 1.0 to 0.0 over a second? 1 Answer
How to hide cursor after pause menu resume 1 Answer
Mathf.Lerp inside a while loop crashes game 2 Answers
OnClick button does not work? Trying to make a pause menu 2 Answers