Projectile Prediction in Unity
Objective: Creating Project Prediction in Unity
Step 1: Project Setup
First, we create a new project and define the launcher and spawn point.
Step 2: The Formula: P(t)=P0+V0t+1/2at²
There are many ways to perform projectile prediction, this guide is using the above formula.
Definitions:
P(t) = position at time
P0 = initial position
V0 = initial velocity (a vector)
a = acceleration (typically gravity g=9.81f
t = time
Step 3: Putting it together
We need to first define the inputs and in order to visualize the projectile prediction, we need to first define a collection of points:
With the amount of points to display clearly defined in the _pointCount variable, we can now loop through each point and calculate the predicted position.
Result: