- Home /
Time goes wrong in the Build
Hello again, @Hellium I have a little question for you, please try to help :)
So I have the effect which decreases its strength by time, everything is just okay in the (UnityEngine), but not in the build, in the build its strength goes very fast to zero, so I can't even see it in the start of the scene, what can make the problem here?
void Update ()
{
oldTV.Strength = Mathf.SmoothStep (1, 0, Time.time / 5);
}
Answer by Hellium · Oct 05, 2018 at 01:49 PM
Because Time.time
is the time in seconds since the start of the game (time starts once all Awake functions have finished), supposing the Start
functions take a lot of time to run, you may have this problem.
Try this:
float startTime ;
void Start()
{
startTime = Time.time ;
}
void Update ()
{
oldTV.Strength = Mathf.SmoothStep (1, 0, (Time.time - startTime ) / 5);
}
Or this:
bool strengthDecreasing ;
float startTime ;
void Update ()
{
if( !strengthDecreasing )
{
strengthDecreasing = true ;
startTime = Time.time ;
}
else
oldTV.Strength = Mathf.SmoothStep (1, 0, (Time.time - startTime ) / 5);
}
Or even better:
float progress;
void Update ()
{
oldTV.Strength = Mathf.SmoothStep (1, 0, progress / 5);
progress += Time.deltaTime ;
}
You're just a Genius for me, Thank you! First example is helped me out
Your answer
Follow this Question
Related Questions
SmoothDamp smoothTime ignored! 1 Answer
MathF.SmoothDamp 2 Answers
How do I increase a speed variable over time? 1 Answer
How does Mathf.SmoothDamp's max speed work? 1 Answer
Different game speed 2 Answers