Spreen provides a Tween-like API for animation and interpolation using springs as a base. Unlike TRANS_SPRING in the Tween library, these springs are defined by damping ratios and halflife.
These help you make fantastic character and camera controllers, reacting to user input in very natural ways.
Spreen builds either as an engine module or as a GDExtension. See Building.
-
Install the GDEXtension, build Spreen as a module, or build as a custom GDExtension. See Building below.
-
Create a Spreen object, optionally binding it to a node (in this case,
self).
var spreen := SpreenTree.create_spreen(self)- Optionally set whether the Spreen can finish, typically you will not want to finish a controller spreen.
spreen.set_finishable(false)- Create and optionally save reference to a property tweener.
var transform_spreen := spreen.spreen_transform_3d(%Box, "global_transform", %Box.global_transform.looking_at(%Target.global_position), 0.5, 0.25)- Update the springs goal in real time.
transform_spreen.update_goal(%Box.global_transform.looking_at(%Target.global_position))Spreen can be built as a Godot module (targeting 4.7+) or GDExtension (targeting 4.3+).
Include this repository in your custom_modules, then build Godot as usual.
The official Spreen GDExtension is built using:
scons target=template_debug api_version=4.3
scons target=template_release api_version=4.3This entire module is based on the math and use-cases presented in this fantastic article by The Orange Duck. If that doesn't convince you, I don't know what will.
Spreen was recently re-written to match the style of Godot's Tween class, but this new version lacks the battle testing of its predecessor. If you find areas that could be improved, please let us know!
This module was originally written by Guillaume Bailey and was re-architected for Godot by Chris Ridenour.
