Angry Birds hold, drag and catapult an object ...

Hi:

I want to be able to hold, drag and catapult an object from a corner of the screen to the opposite corner at an angle and speed from my drag. Download the #1 game on the Apple Store to see what I mean.

Help,

Chepe

Copying Tetrad's comment since he didn't post it as an answer...

Well you usually have some position in the world that your sling shot is in (`originalPosition`). You can for example set that position on mouse down.

Then your drag will move your projectile to some other position in the world (`draggedPosition`). You could set that position on mouse up.

Subtract these two vectors to get a new vector from the projectile to the sling shot:

var shootVector = originalPosition - draggedPosition;

Use the vector's direction to set the force direction, and the magnitude to set the force amount (where further away is higher force magnitude, obviously). Actually you can do that just by setting the force directly to the vector, possibly with a multiplier:

projectile.rigidbody.AddForce(shootVector * multiplier, ForceMode.Impulse);

From there's it's usually a matter of just making sure your physics properties are set up right. More info here:

http://unity3d.com/support/documentation/Manual/Physics.html

I know how to drag the object but what would be the best way to calculate the force and angle based on the position of the drag. Again Im an artist, so Im giving it my best shot. I will post my code here very soon ...