See all glossary terms

Interpolation

Interpolation is the process of inferring and calculating unknown values based on some data points and a formula.
When you use tweens or the animation editor in Godot, the engine calculates new values each frame based on your animation keyframes and easings. This is an example of interpolation.
For example, in this tween code, we animate a sprite moving from its current position to the position Vector2(500, 400) over 2 seconds:
var sprite_2d: Sprite2D = get_node("Sprite2D")
var tween := create_tween()
tween.tween_property(sprite_2d, "position", Vector2(500, 400), 2.0)
The tween calculates the sprite's position each frame based on the time elapsed over 2 seconds. If we don't specify a transition function, the tween object does this using linear interpolation: the sprite moves at a constant speed from its current position to the target position.