Beginner Here. I was watching a tutorial on how to make a pathway projection using line renderer. And it worked. I can input a initial velocity and a angle and it renders the path it would follow. But now I want to have an object follow this pathway. How would I go on about this?
Pathway Projection Code
void RenderArc()
{
lr.positionCount = resolution + 1;
lr.SetPositions(CalculateArcArray());
}
//calculates the points needed to the arc
Vector3[] CalculateArcArray()
{
Vector3[] arcArray = new Vector3[resolution + 1];
radianAngle = Mathf.Deg2Rad * angle;
float maxDistance = (velocity * velocity * Mathf.Sin(2 * radianAngle)) / gravity;
for(int i = 0; i <= resolution; i++)
{
float t = (float)i / (float)resolution; //ensures all points are equally spaced
arcArray *= CalculateArcPoint(t, maxDistance);*
}
return arcArray;
}
//calculate height and distance of each vertex
Vector3 CalculateArcPoint(float t, float maxDistance)
{
float x = t * maxDistance;
float y = x * Mathf.Tan(radianAngle) - ((gravity * x * x) / (2 * velocity * velocity * Mathf.Cos(radianAngle) * Mathf.Cos(radianAngle)));
return new Vector3(x, y);
}