Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Projectile position at specific time

$
0
0
Hey guys, i'm having a bit of a hard time finding the position of a projectile at a specific time. I have a start point, a velocity, and some acceleration. I know the time that the projectile has been in motion, t and some distance let's say d. Let's assume the distance is 20 and t is 0.5. In this scenario i want to find out where the projectile should be when it's 10 units from where it was shot off from. I hope that makes sense.... I found this bit of code online, but i'm not sure how to actually plug my values in... // Parabolic motion equation, y = p0 + v0*t + 1/2at^2 float ParabolicCurve(float p0, float v0, float a, float t) { return p0 + v0 * t + 0.5f * a * t * t; } Vector3 ParabolicCurve(Vector3 p0, Vector3 v0, Vector3 a, float t) { Vector3 ret = new Vector3(); for (int x = 0; x < 3; x++) ret[x] = ParabolicCurve(p0[x], v0[x], a[x], t); return ret; } The problem i'm having is the above function works with respect to time. IE, if i want to find the position at a given distance instead of a given time....

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>