Jump to content

Linear Interpolation: Difference between revisions

Added more information (merged "Basics of tweening" from the old wiki)
m (Text replacement - "Category:Scripts" to "Category:Scripting")
(Added more information (merged "Basics of tweening" from the old wiki))
 
Line 30: Line 30:
The Amount variable increases by 0.05 every frame, until it reaches 1, where it is limited by using [[Min]].
The Amount variable increases by 0.05 every frame, until it reaches 1, where it is limited by using [[Min]].


As a convenient script to interpolate between values non-linearly (for example, make it slowly gain speed at the start and reduce speed at the end, which is more natural for animations), you can use [https://play.fancade.com/5E6AB5ADF3B3BC2F Easings] by [[Sounak9434]].
== Non-linear interpolation ==
 
It is often useful to make the movement more believable by having some acceleration (making it non-linear) without the use of physics.
Apart from interpolation, this technique is sometimes called tweening or easing.
 
To do this, instead of using the Amount variable directly, it can be transformed first.
You can raise it to some [[power]] or take a [[sin]] or use a function like <b>smoothstep</b>, which will make the movement smoothly accelerate and then decelerate; it looks like this:
 
{{Image|Smoothstep.png}}
{{Image|Smoothstep_graph.png}}
 
You can experiment with such easing functions on your own or find some elsewhere on the internet or in Fancade, such as in [https://play.fancade.com/5E6AB5ADF3B3BC2F Easings] by [[Sounak9434]].


[[Category:Scripting]]
[[Category:Scripting]]