- Home /
Perfect oblique launch from point A to point B
Hey everyone, I'm with some tricky doubt here. Imagine we have a cannon which can shoot balls. In the 3D world I have an aim, which is the position where I want the ball to go. What's the best way to make the ball go in some sort of oblique launch in direction of the aim? Should I use AddForce based on distance between the cannon and the aim position in world ? Someone already implemented such a thing with success? It's not difficult to make the ball get closer to the aim. But what about make her hit the ground perfectly in the aim position?
Thanks from now!
Cheers.
Yes, just add a force. You could set the velocity.
Just use normal high-school physics to figure out what the initial velocity should be for the angle you are using.
Thanks for the reply! I just taked a look at the angle function. I missed her. Now I think I'll get some results. I was considering the use of high-school physics(why create a new formula if we already have one, isn't? hehe) but I wasn't sure about the velocity. How I would convert force to velocity, but I forgot I can set the velocity by myself. =)
Were you not aware of Unity's built-in physics engine, or are you trying to avoid using it for network / performance reasons?
Well. In my current project I want to avoid physics simulation as far as I can because it's a A.R game for mobile, so...
Unitard, I think he just wants to know WHAT initial velocity to use, so that the ball WILL land in a certain spot. ie, yes the ball will travel under Unity's physics.
Is that right, José ?
Guto, there is absolutely no problem using Unity's physics in your AR game.
it sounds like you have a long way to go in mastering Unity, before performance will be an issue! enjoy!!
Answer by TowerOfBricks · May 25, 2012 at 02:58 PM
That will require some math/physics. And I would not recommend using the Unity physics to do it. Setting the position of the ball is more stable. See this wikipedia page for more information: Trajectory of a Projectile I have done the maths before when I programmed a TD game, but I haven't got the code left.
he's talking about PREDICTING the RESULT of using the PhysX to throw a stone. (which is - obviously - exactly the same as predicting it in the real world.) this has been explained some three times now :)