Comments and answers for "How do I arc a rigidbody so it lands on a target?"
http://answers.unity.com/questions/157390/how-do-i-arc-a-rigidbody-so-it-lands-on-a-target.html
The latest comments and answers for the question "How do I arc a rigidbody so it lands on a target?"Comment by AkooleGame on AkooleGame's answer
http://answers.unity.com/comments/961867/view.html
Link is broken.Thu, 07 May 2015 10:32:47 GMTAkooleGameComment by neroziros on neroziros's answer
http://answers.unity.com/comments/307680/view.html
I'm looking for a way to make the same but with variable angles (from 30 to 80 degrees) any suggestions? Thanks in advance for your time!Fri, 24 Aug 2012 23:56:55 GMTnerozirosAnswer by aldonaletto
http://answers.unity.com/answers/157439/view.html
I answered a similar question some time ago - the cannon shoot at 45 degrees and the ball always land on the target position (unless the target runs away before). [Clike here][1] to read this answer.
[1]: http://answers.unity3d.com/questions/145972/how-to-make-enemy-canon-ball-fall-on-mooving-targe.htmlWed, 17 Aug 2011 10:01:30 GMTaldonalettoComment by Julien-Lynge on Julien-Lynge's answer
http://answers.unity.com/comments/157419/view.html
BTW: just so we're clear, the case is exactly the same as for all the other 2D platformer game examples you mention, except that in those examples we assume that we're firing in the positive X direction. For an angle from positive X of theta, the amount of velocity in X and Z changes by:
X = origVal * Cos(theta)
Z = origVal * Sin(theta)
Once you fire off the projectile, you don't have to do any other math, as Unity will apply gravity for you.Wed, 17 Aug 2011 08:51:03 GMTJulien-LyngeAnswer by Julien-Lynge
http://answers.unity.com/answers/157416/view.html
First of all, if you want to spend money and exert minimum effort the free iTween package for Unity has an example project that does pretty much exactly what you're looking for ( http://itween.pixelplacement.com/examples.php ). The package of examples costs $20, so you may not want to go that route.
If you wanted to do it numerically / with realistic physics, you'd have to solve a few of basic physics equations. You have two variables that describe the motion: the initial velocity and the firing angle. Wikipedia has a great section on the parabolic equation you would need:
http://en.wikipedia.org/wiki/Trajectory#Uniform_gravity.2C_no_drag_or_wind
In a nutshell, you plug in your desired velocity or angle and range to get the required angle or velocity to hit your target. Then, turn on gravity for the rigidbody and set the initial velocity of the rigidbody. Assuming we're firing in the positive X direction:
rigidbody.velocity = new Vector3(desiredVel * Mathf.Cos(desiredAngle), desiredVel * Mathf.Sin(desiredAngle), 0f);
In any other direction the Y velocity is the same and you change the X and Z trigonometrically based on your angle around the Y axis.
If you wanted friction from the air this becomes a differential equation, and you should consult your local mathematician.Wed, 17 Aug 2011 08:48:07 GMTJulien-LyngeComment by Waz
http://answers.unity.com/comments/157406/view.html
You have to do your own physics calculations. There is no exposed Unity functionality for that. I suggest you implement the case without drag.Wed, 17 Aug 2011 08:27:21 GMTWaz