Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Our educational partners
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
Hello! I would gradually increase a numeric variable... I have a numeric Global Variable, for example equal to -300, and I want it after an event becomes equal to -600. Can I gradually pass from -300 to -600 in one second? I don't understand the lerp expression...
Thank you very much!!!
If you need to change from -300 to -600, that's actually decreasing
This should decrease X by 300 every second.
To stop after 1 second, you can either set a condition "If X>-600" or add Clamp() or Max() expression, for example:
If you want easing effects (speeding up/down etc), you can install LiteTween behavior.
You're right sorry, the variable decreases!
I thought there was something easier
Meanwhile I try with your suggestions, thanks a lot. If you also have other ideas, write
I think I've succeeded with LiteTween!
Develop games in your browser. Powerful, performant & highly capable.
LiteTween is an overkill for this task if you just need a linear change.
X=X-300*dt is the easiest formula
If you don't care about it taking precisely 1 second, you can simply subtract 5 every tick:
At 60fps it would take approximately 1 second to decrease by 300.
You can do this with lerp if you want, but you will need another variable "t":
X=lerp(-300, -600, t)
Yes, at the beginning I tried with lerp expression.
But I don't understand the third value and therefore it didn't work.
Set X to lerp(-300,-600,0.5*dt), but the value changes immediately.
Same thing with:
"dt" is frame duration and at 60fps it's always approximately 0.016
That's why your formula always returns the same result.
You can try this:
X=lerp(X, -600, 0.5*dt)
It still doesn't work.... But I'm fine with the LiteTween, for now. Thanks for the help!