How do you throw a curveball in Unity?
Throwing a Curveball in Unity
To throw a curveball in Unity, usage of the Physics and Rigidbody components is necessary. Subsequently, apply both forward and rotational impulses will cause the ball to behave in a curveball manner.
public Rigidbody rb; // The Rigidbody attached to the ball
public float speed; // The speed the ball is to be thrown at
public float curve; // The curvature of the throw
void ThrowCurveBall() {
// Apply forward force
rb.AddForce(transform.forward * speed);
// Apply rotational force
rb.AddTorque(transform.right * curve);
}