Table of Contents

Class Curve

Namespace
Godot
Assembly
GodotSharp.dll

This resource describes a mathematical curve by defining a set of points and tangents at each point. By default, it ranges between 0 and 1 on the Y axis and positions points relative to the 0.5 Y position.

See also Gradient which is designed for color interpolation. See also Curve2D and Curve3D.

public class Curve : Resource, IDisposable
Inheritance
Curve
Implements
Inherited Members

Constructors

Curve()

public Curve()

Properties

BakeResolution

The number of points to include in the baked (i.e. cached) curve data.

public int BakeResolution { get; set; }

Property Value

int

MaxValue

The maximum value the curve can reach.

public float MaxValue { get; set; }

Property Value

float

MinValue

The minimum value the curve can reach.

public float MinValue { get; set; }

Property Value

float

PointCount

The number of points describing the curve.

public int PointCount { get; set; }

Property Value

int

_Data

public Array _Data { get; set; }

Property Value

Array

Methods

AddPoint(Vector2, float, float, TangentMode, TangentMode)

Adds a point to the curve. For each side, if the *_mode is Linear, the *_tangent angle (in degrees) uses the slope of the curve halfway to the adjacent point. Allows custom assignments to the *_tangent angle if *_mode is set to Free.

public int AddPoint(Vector2 position, float leftTangent = 0, float rightTangent = 0, Curve.TangentMode leftMode = TangentMode.Free, Curve.TangentMode rightMode = TangentMode.Free)

Parameters

position Vector2
leftTangent float
rightTangent float
leftMode Curve.TangentMode
rightMode Curve.TangentMode

Returns

int

Bake()

Recomputes the baked cache of points for the curve.

public void Bake()

CleanDupes()

Removes duplicate points, i.e. points that are less than 0.00001 units (engine epsilon value) away from their neighbor on the curve.

public void CleanDupes()

ClearPoints()

Removes all points from the curve.

public void ClearPoints()

GetPointLeftMode(int)

Returns the left Curve.TangentMode for the point at index.

public Curve.TangentMode GetPointLeftMode(int index)

Parameters

index int

Returns

Curve.TangentMode

GetPointLeftTangent(int)

Returns the left tangent angle (in degrees) for the point at index.

public float GetPointLeftTangent(int index)

Parameters

index int

Returns

float

GetPointPosition(int)

Returns the curve coordinates for the point at index.

public Vector2 GetPointPosition(int index)

Parameters

index int

Returns

Vector2

GetPointRightMode(int)

Returns the right Curve.TangentMode for the point at index.

public Curve.TangentMode GetPointRightMode(int index)

Parameters

index int

Returns

Curve.TangentMode

GetPointRightTangent(int)

Returns the right tangent angle (in degrees) for the point at index.

public float GetPointRightTangent(int index)

Parameters

index int

Returns

float

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

RemovePoint(int)

Removes the point at index from the curve.

public void RemovePoint(int index)

Parameters

index int

Sample(float)

Returns the Y value for the point that would exist at the X position offset along the curve.

public float Sample(float offset)

Parameters

offset float

Returns

float

SampleBaked(float)

Returns the Y value for the point that would exist at the X position offset along the curve using the baked cache. Bakes the curve's points if not already baked.

public float SampleBaked(float offset)

Parameters

offset float

Returns

float

SetPointLeftMode(int, TangentMode)

Sets the left Curve.TangentMode for the point at index to mode.

public void SetPointLeftMode(int index, Curve.TangentMode mode)

Parameters

index int
mode Curve.TangentMode

SetPointLeftTangent(int, float)

Sets the left tangent angle for the point at index to tangent.

public void SetPointLeftTangent(int index, float tangent)

Parameters

index int
tangent float

SetPointOffset(int, float)

Sets the offset from 0.5.

public int SetPointOffset(int index, float offset)

Parameters

index int
offset float

Returns

int

SetPointRightMode(int, TangentMode)

Sets the right Curve.TangentMode for the point at index to mode.

public void SetPointRightMode(int index, Curve.TangentMode mode)

Parameters

index int
mode Curve.TangentMode

SetPointRightTangent(int, float)

Sets the right tangent angle for the point at index to tangent.

public void SetPointRightTangent(int index, float tangent)

Parameters

index int
tangent float

SetPointValue(int, float)

Assigns the vertical position y to the point at index.

public void SetPointValue(int index, float y)

Parameters

index int
y float

Events

RangeChanged

Emitted when MaxValue or MinValue is changed.

public event Action RangeChanged

Event Type

Action