# Throw object towards predefined place? [duplicate]

I have a 2D side-view game with object attributes such as x, y, speedX, etc. Now I want to throw a given object from any place on the screen onto a defined goal place, in such a way that its trajectory looks somewhat normal (with gravity, it making a curve and such). Imagine an enemy is destroyed and what he stole flies from him back towards the stolen object's origin. (I do have physics via Box2D in this game, but for this particular need, it seems I require a manual approach; for one thing, the object is allowed to pass other bridges and such for the time it flies back to its main bridge.)

How would I go about this? I've tried moving manually by adjusting towards a target speed and such, but the trajectory and timing looks very unnatural. Thanks! Wiki has article about projectile trajectory here.

Maybe also this will help you (it helped me). It's brief explanation of two approaches to your problem - variable strength and angle of projectile being shoot. At the end of this post, there's short "Try it yourself!" section, where small JavaScript implementation exists (which may, again, help you).

Good luck!

One approach would be to use a parabolic trajectory, which is the shape that normal projectiles take.

We can use three points to define the parabola:

• Initial object position
• Final object position
• Turning point

The turning point can be a constant horizontal and vertical distance away from the target, it just needs to flip slides to suit the initial position. The parabola equation we are using is Solve the following simultaneous equations to find a and b. Now we might be interested in finding the launch angle and a velocity. First we manipulate the projectile motion equations to obtain the following The above equation takes the parabolic form we outlined above. To find the launch angle theta we can simply use If we know the animation time t we can find the launch velocity v_0 with • I waited because I wasn't sure which of the two replies to mark as answers. Yours is extensive and great but I should have clarified that I was looking more for code or pseudo code. Apr 12 '13 at 7:35