2
\$\begingroup\$

I'm stuck on how to make a preview trajectory for a projectile appear when holding a button. The trajectory should start at a certain position on the scene and end wherever the player points their mouse. On mouse click, a projectile should be launched along that trajectory with the clicked position as its target.

How can I do this?

\$\endgroup\$
  • \$\begingroup\$ Hey, I tried the following code: wiki.unity3d.com/index.php/Trajectory_Simulation, And the following assets: assetstore.unity3d.com/en/#!/content/42720, assetstore.unity3d.com/en/#!/content/12306, assetstore.unity3d.com/en/#!/content/8358. But I never got any of them to work the way I wanted and I never made a full version of any code I wrote by myself and I kept remaking them over and over. I've never been good with physics programming so now I'm just trying to find an already made package because I'm just not good with physics and I never was. \$\endgroup\$ – Ssiro Oct 24 '15 at 22:41
  • 1
    \$\begingroup\$ Look, game programming is not the easiest task out there. You'll face a lot of different problems, and of course you are not supposed to know how to solve them on top off your head. I suggest you keep calm read on until it makes sense to you. Sometime ago, I found this tutorial for displaying trajectory path before I wrote a tutorial not about the displaying of the motion, but rather about the trajectory motion physics itself. \$\endgroup\$ – Varaquilex Oct 24 '15 at 22:48
  • \$\begingroup\$ The complication here is that there is an infinite family of parabolic arcs joining two points, so we need some additional constraints to be able to choose which one to draw. Can you also clarify whether you're looking for help with the math of expressing the curve, or the code/components to render that curve visually? \$\endgroup\$ – DMGregory Oct 25 '15 at 1:04
  • \$\begingroup\$ Also "wherever the player points his mouse" might be a problem. Keep in mind you need to cast a ray through the cursor into the world (unproject) to find the 3d coordinates of the endpoint in world-space. \$\endgroup\$ – Chris Oct 25 '15 at 2:43
  • \$\begingroup\$ Hey, thank you all for your answers. @Varaquilex - Im gonna try that as soon as I get home. -DMGregory - Im trying to visualize the whole thing, throwing isn't an issue. -Chris - Yes, that's what has been bothering me the most. \$\endgroup\$ – Ssiro Oct 25 '15 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.