I’m trying to write a realistic grenade throw. I’m using the below code to draw a line renderer arc between my player and and a point that follows the mouse.
void Update(){
var pointList = new List<Vector3>();
float vertecCount = 12;
for(float ratio = 0; ratio <=1; ratio += 1 / vertecCount){
var tangent1 = Vector3.Lerp(transform.position, point2.position, ratio);
var tangent2 = Vector3.Lerp(point2.position, grenadeTarget.transform.position, ratio);
var curve = Vector3.Lerp(tangent1, tangent2, ratio);
pointList.Add(curve);
}
grenadeArc.positionCount = pointList.Count;
grenadeArc.SetPositions(pointList.ToArray());
}
How can I instantiate a sphere and throw it along the line renderer using AddForce? I need to use the rigidbody so the grenade can bounce realistically.