Thank you, @Baz ![]()
Building on top of your answer, my goal was to refactor the function so that i could use it for both Curves (Attack and Decay).
It’s typewritten like this now:
var _scale_curve: Callable = func(curve: Curve) -> Curve:
var _scale_point_value: Callable = func(value: float) -> float:
return remap(
value,
curve.sample(curve.get_max_domain()),
curve.sample(curve.get_min_domain()),
curve.sample(curve.get_max_domain()),
sample,
)
var _output_curve: Curve = curve.duplicate()
for _point in curve.get_point_count():
var _y : float = curve.get_point_position(_point).y
_output_curve.set_point_value(
_point, _scale_point_value.call(_y)
)
return _output_curve
Notes:
-
The function no longer changes the
_scaled_release_curveby itself.
It nowreturns a scaled version of the inputcurve,
so this line outside the function sets_scaled_release_curve:_scaled_release_curve = _scale_curve.call(release_curve) -
I remembered that i started coding this Add‑on before Godot 4.4.
Godot 4.4 added themin_domainandmax_domainproperties toCurve,
so i changed the Lookup of Curves’ first Position and last Position to a simpler Way,
how i would have done it if i started the Project today.Lookup Before After First
Positionrelease_curve.get_point_position(0).ycurve.sample(curve.get_min_domain())Last
Positionrelease_curve.get_point_position( release_curve.get_point_count() - 1 ).ycurve.sample(curve.get_max_domain())I chose
sampleinstead ofsample_bakedbecause i expect developers using my Add‑on to change the Curves at Runtime.