Launch arc with physics/rigidbody problem and on Unity's internal code

All the tutorials I’ve seen on this require you to use trajectory formulas (E.g. Rendering a Launch Arc in Unity - YouTube) but that has it’s own problems. Now I have to find the angle and velocity. I use Addforce with forcemode.impulse though, so I have to convert that to velocity somehow. And as far as i can see there is no easy way to find the angle (I tried vector.Angle, but that only gives between 0-180).

What I’m thinking is, doesn’t Unity already have all the formulas built into the engine? When I use Addforce with forcemode: impulse, it has to calculate the trajectory of my rigidbody anyway, so why can’t i access that?
I tried looking in the documentation and in Unity’s engine, but I can’t find anything. Does anyone here know?

Hey there,

as far as i know the short answers is sadly no.

Unity does NOT calculate trajectories up front, at least not the complete trajectory. This has multiple reasons in which i do not want to dive too deeply. (If you want to learn more about this then look into system theory for machanics and dynamic systems) Basically what unity does is iterate all the physics in multiple step but just for the next frame. So there is some slight prediction there, but just for 1 frame in the future to check for collisions. Any more calculation will be just useless since the whole setup might change due to scripts. (e.g. you reset some positions, add new objects…) And useless calculations equals to bad performance here. So yes in some way the equations exist somewhere deep in the physics system but are probably not accessible to you. If you really only want to create a simple parabola for a certain object with given mass and constant gravity then you should rather just calculate this on your own.

If you need help with this feel free to ask, it’s not that difficult and one can learn quite a lot when trying this :slight_smile:
You can also look at this question for reference. This question was about making an object always hit the same point with disregard for the launch angle and mass. So here we had to calculate a fitting “gravity”.
When you have the formula for whatever you need then creating a line from it is the easy part.