How to check where a solid will land before throwing it out?

I want to have a cannon, and when the player is adjusting the force applied to fire, I would like to show where the cannonball will land.

It looks like the formula for what I want is here: http://en.wikipedia.org/wiki/Trajectory#Uniform_gravity.2C_no_drag_or_wind , however I would like to know if this is something that unity can provide me with, without coding the formula (since it's obviously already used in unity) one reason is that I don't want to be wrong when my calculations don't match one when the cannonball is actually fired.

+3


source to share


1 answer


Unfortunately, the physics of Unity is not deterministic. I've seen several teams trying to implement something like this. It takes a long time, and usually one of the following approaches is done at the end:



  • Using your own custom deterministic physics - but this is usually very time consuming and requires significant changes throughout the project.
  • Approximation of physics of Unity with a special code - but it is inaccurate and may differ from the final result
  • Speeding up Unity physics, starting an invisible clone of an object with the same parameters, and then displaying the path it took - still takes a while to compute. Ask the game designers if they are okay with the trajectory appearing with "animation" that starts every time the player moves the cannon - the "animation" will of course be the actual movement of the invisible cloning of the cannonball.
+3


source







All Articles