# Moving object beyond Bezier Curve

I am currently developing small 2D game in Unity, in which player is using swipe to create objects paths. I already did almost everything, but I hit a wall which i cannot pass. The thing is, that when I am using Bezier Curve I have to specify all points to have a base for my curve, but I'd like my object to move further after passing end point. Look at the image.

I've created a curve based on points A, B and C. The curve is green, but it doesn't reach the screen end, so I'd like to extend it with the red line. This my code to get a point on a curve.

public static Vector3 GetPoint(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
{
t = Mathf.Clamp01(t);
float oneMinusT = 1f - t;
return
oneMinusT * oneMinusT * oneMinusT * p0 +
3f * oneMinusT * oneMinusT * t * p1 +
3f * oneMinusT * t * t * p2 +
t * t * t * p3;
}


I heard that passing parameter T greater than 1 should acutally do the thing, but it does not always work with my curves. Sometimes the object starts to go backwards or goes into some random direction. I would be grateful if someone could help me solve this problem. Thank you.

• Your diagram shows 3 points, A/B/C (sufficient for a quadratic Bézier curve), but your code shows 4 points, p0-p3 (sufficient for a cubic).Are you doubling one of the points? That may be the cause of the unpredictable behaviour when overshooting. If you only need 3 points, consider using a Bézier curve of lower degree. – DMGregory Oct 7 '16 at 15:27