I have a "Curve" and would like to sample it with a value between 0 to 1, but sometimes I want my sample number to be higher than 1 (1.2 in this case). However it seems that using any number higher than 1 to sample a curve only returns the curve's Y value number at position 1. Is it not possible to extrapolate on a curve like this?

e.g.
@export var curve: Curve
var sample_value = 1.2
var returned_value = curve.sample(sample_value)

  • xyz replied to this.

    Vespher I don't think you can sample out of 0-1 range. Which method of extrapolation would you expect it to have? If it's just a linear extension along the tangent then you can easily calculate that.

    Here's a quick mspaint, just looking to get a result like this

    It's possible to extend the maximum Y axis value, but not the maximum X axis value, which is the axis your sample uses.

    So I guess I need to figure something else out for a similar effect that doesn't use a curve?

    I have a very..... lame solution.

    Use a second curve. If my sample is above 1, subtract 1 and apply it to the second curve. Lol...... it works though 🙂

    Here's code:

    func _get_curved_value(value: float) -> float:
    	if value > 1:
    		return curve_one.sample(value - 1) + 1
    	else:
    		return curve_two.sample(value)

    If you want results for inputs over 1, then why not just have one curve do it all and divide input by 2? Another curve feels like turning it up to 11: