Pre-drawing the path of a projectile

Topics: Developer Forum, User Forum
Aug 9, 2010 at 10:02 AM

I'm guessing this is a problem some of you will have solved before.  This is probably not the correct forum for this question but I'm sure some of you will have implemented this before, so hopefully I can get the info.  I want to draw a curve with an arrowhead slapped on the end to represent a projectiles path before the force has been applied to it.  The way I implemented it on my last attempt was to add an object with the same properties as the object about to get fired off, add it to its own collision plane, launch it and then take points along its path.  However this is too slow as the user has to wait the same amount of time it would take for it to occur anyway.  I want the line and arrow to be instantly there so the user can adjust it.  My next idea is to add a new World set it up the same as the level, apply the force to the object then in a for loop or something make the World step a tenth of a second at a time and store the balls location on each pass through, store all the info in a list then in my real game loop draw it properly. Phew.  Is there a better plan for this ..... I'm thinking there probably is.

Aug 9, 2010 at 2:42 PM

Not sure how you would go about doing that, but you can actually simulate the path by using a parametric equation where x = c*t + b (where c is a constant and b is an initial value) and y = ct^2 + b. You'll just need to customize the values of c and b to your simulation. Of course things get more complex if you have any sort of damping and this equation will become wildly inaccurate, so I'm not sure what you'd do in that case.