How to create a variable which is an unique, changed copy of a Curve?

Thank you, @Baz :+1:

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 now returns a scaled version of the input curve,
    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 the min_domain and max_domain properties to Curve,
    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.

    LookupBeforeAfter
    First
    Position
    release_curve.get_point_position(0).y
    
    curve.sample(curve.get_min_domain())
    
    Last
    Position
    release_curve.get_point_position(
    	release_curve.get_point_count() - 1
    ).y
    
    curve.sample(curve.get_max_domain())
    

    I chose sample instead of sample_baked because i expect developers using my Add‑on to change the Curves at Runtime.