Title says it all. I need to pre-calculate the physics for a flightpath (projectile motion) with several forces acting on the object. (drag, lift from spin, angular drag, wind) I need to calculate these very fast as they will be used for a golf game aiming system on the easier difficulty. Also need to pre-render a sphere rolling on a terrain mesh. Looking into switching timescale but it will probably require tons of script changes. Any solutions would be appreciated! If nothing else I can always write my own physics code..
Thanks guys!
There isn’t any option on the physics engine to work out where an object will end up without running the simulation. If you need high accuracy then it is best to write your own code to handle the motion of the ball rather than attempt to calculate how the physics simulation will work out.
Using standard trajectory formulas work very well in predicting the trajectory of a projectile, but I’ve yet to figure out the formula for Unity’s drag.
Any hints on that, Andeeee?
As far as spin, lift, wind - you would have to roll your own code which then makes prediction easy.
If you use drag, it makes it very hard to come up with a formula. Using a precalculated table and then interpolating works well. I use it for both the prediction and the actual ‘physics’ as well. It is very convincing, if not 100% accurate. I’m happy to post code fragments if you are interested. You’d have to account for your other forces too as I just handle drag and gravity, but that shouldn’t be hard to change.
You could use a 3d modeling program like 3ds Max to create a predefined path, and physics generation. then import the whole thing as a single FBX. Attach cameras and the like. That would give you exactly what you are looking for.