The Vector3.CubicBezier
method calculates a point on a cubic Bezier curve defined by two endpoints and two tangents. This method is useful for creating smooth curves in 3D space.
The Vector3.CubicBezier
method calculates a point on a cubic Bezier curve defined by two endpoints and two tangents. This method is useful for creating smooth curves in 3D space.
To use the CubicBezier
method, provide the following parameters:
source
: The starting point of the curve.target
: The ending point of the curve.sourceTangent
: The tangent vector at the starting point, which influences the curve's initial direction.targetTangent
: The tangent vector at the ending point, which influences the curve's final direction.t
: A float value between 0 and 1 that represents the interpolation factor along the curve.The method returns a Vector3
representing the point on the curve at the specified interpolation factor t
.
// Example usage of Vector3.CubicBezier Vector3 start = new Vector3(0, 0, 0); Vector3 end = new Vector3(10, 10, 0); Vector3 startTangent = new Vector3(5, 0, 0); Vector3 endTangent = new Vector3(5, 10, 0); float t = 0.5f; // Midpoint of the curve Vector3 pointOnCurve = Vector3.CubicBezier(ref start, ref end, ref startTangent, ref endTangent, t); // pointOnCurve now holds the position at the midpoint of the cubic Bezier curve.