x


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.

more ▼

asked May 25 '12 at 04:14 AM

GutoThomas gravatar image

GutoThomas
593 32 46 47

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.

May 25 '12 at 06:26 AM Fattie

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. =)

May 25 '12 at 01:55 PM GutoThomas

Were you not aware of Unity's built-in physics engine, or are you trying to avoid using it for network / performance reasons?

May 25 '12 at 02:08 PM Kiloblargh

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...

May 25 '12 at 02:13 PM GutoThomas

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!!

May 25 '12 at 02:23 PM Fattie
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered May 25 '12 at 02:58 PM

TowerOfBricks gravatar image

TowerOfBricks
3.2k 17 25 50

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 :)

May 25 '12 at 04:27 PM Fattie
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1866
x244
x51

asked: May 25 '12 at 04:14 AM

Seen: 444 times

Last Updated: May 25 '12 at 04:28 PM