Comments and answers for "rocketscience - how to find out what force is needed to hit a specific target"
http://answers.unity.com/questions/407480/rocketscience-how-to-find-out-what-force-is-needed.html
The latest comments and answers for the question "rocketscience - how to find out what force is needed to hit a specific target"Comment by headkitgames on headkitgames's answer
http://answers.unity.com/comments/409226/view.html
the velocity v_y0 from UPForce is calculated via
float v_y0 = jumpVelocity * Time.fixedDeltaTime; // rigidbody.mass = 1
that works fine, but the x-velocity is way to high! how could that be...?Fri, 01 Mar 2013 22:36:23 GMTheadkitgamesComment by headkitgames on headkitgames's answer
http://answers.unity.com/comments/408620/view.html
really nice, thanx. So I now have something like
float y = closestPlate.transform.position.y;
float y_0 = transform.position.y;
float v_y0 = jumpVelocity; // ??? HOW TO CALCULATE? UPFORCE HERE IS 700
float x = closestPlate.transform.position.x;
float x_0 = transform.position.x;
float v_x0 = (x - x_0) / (float)( ($$anonymous$$athf.Sqrt (2 * $$anonymous$$athf.Abs(Physics.gravity.y) * y - 2 * $$anonymous$$athf.Abs(Physics.gravity.y) * y_0 + $$anonymous$$athf.Pow(v_y0, 2) ) - v_y0) / $$anonymous$$athf.Abs(Physics.gravity.y) );
pathBullet = (GameObject)Instantiate(pathBulletPrefab);
pathBullet.transform.position = transform.position;
pathBullet.rigidbody.velocity = new Vector3($$anonymous$$athf.Sign(distanceVectorToNextPlate.x)*v_x0, v_y0 , 0);
but how could I now calculate the starting-velocity v_y0 from my starting UPForce ?Thu, 28 Feb 2013 21:37:07 GMTheadkitgamesComment by Tarlius on Tarlius's answer
http://answers.unity.com/comments/407610/view.html
From the [docs][1]:
"A typical example where you would change the velocity is when jumping in a first person shooter, because you want an *immediate change in velocity*."
As I said, you can achieve the effect by applying a force for one physics frame (which would be equivilant to applying the force constantly for 1/60 seconds), but its easier to do it with velocity.
If you apply a constant force of over 9.81 in the y direction, you will never come down.
It will follow a parabola because of gravity, lack of upwards thrust (net acceleration downwards) and a constant horizontal velocity.
Anyway, it seems I've misread the question. I thought the start-point was where the rocket is in the diagram and it had to go through both. The problem is much simpler ^^;;
[1]: http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-velocity.htmlWed, 27 Feb 2013 13:54:43 GMTTarliusComment by MickM
http://answers.unity.com/comments/407578/view.html
Time to rise to highest point of flight = velocityVerticle/gravity
If you are firing at the same y that you land, the overall time is just double the above (which you can put into step 2 from initial reply )
If not... A good resource is
http://www.makingthemodernworld.org.uk/learning_modules/maths/04.TU.02/?section=13
Sorry it had been years since I did physics and don't have time to look more... Good luck again!!!Wed, 27 Feb 2013 13:15:16 GMTMickMAnswer by steakpinball
http://answers.unity.com/answers/407577/view.html
Set `rigidbody.velocity` to the desired value.
The equation `t = (-sqrt(2 * a * y - 2 * a * y_0 + (v_y0)^2)-v_y0) / a` will give you the time it takes to move in the y direction. Use that in `v_x = (x - x_0) / t` to get the initial horizontal velocity. Where:
- `a` is acceleration due to gravity
- `y` is destination y position
- `y_0` is starting y position
- `v_y0` is initial y velocity
- `x` is destination x position
- `x_0` is starting x position
- `v_x` is desired x velocity
You can even make it one formula if you are feeling adventurous. Please don't make me write the literal code for this formula.
http://www.wolframalpha.com/input/?i=Solve+%5By%3D%3Dy_0%2Bv_0*t%2B%281%2F2%29at%5E2%2C+t%5D
http://www.wolframalpha.com/input/?i=Solve+%5Bx%3D%3Dx_0%2Bv_0*t%2C+v_0%5DWed, 27 Feb 2013 13:13:07 GMTsteakpinballComment by headkitgames
http://answers.unity.com/comments/407576/view.html
hey, thanx! shure, this would bring dy = 0-(((0.5*gravity*(time*time))+starty-endy)/time). but what about the time, from where would I get it?Wed, 27 Feb 2013 13:10:35 GMTheadkitgamesComment by headkitgames on headkitgames's answer
http://answers.unity.com/comments/407573/view.html
hey, thanx for answering. I think using addForce is the right way to force an object to move. think of it as giving an impulse to the object, only for one moment. due to inertia of masses it will flow on a parabolic path. the second plate is meant to be on a higher level than the first one.Wed, 27 Feb 2013 13:03:49 GMTheadkitgamesComment by MickM
http://answers.unity.com/comments/407568/view.html
First step, calculate time for it to arrive back at the required y
Starting point: http://hyperphysics.phy-astr.gsu.edu/hbase/traj.html#tra1
Second, divide the x distance by the time from step 1
Sorry I can't get the the first formula offhand (simple enough to make time the subject of vertical trajectory though)
Also
http://blitzbasic.com/Community/posts.php?topic=68027
Or
http://www.mathisfunforum.com/viewtopic.php?pid=35032
$$anonymous$$ight help
Good luck!Wed, 27 Feb 2013 12:55:42 GMTMickMAnswer by Tarlius
http://answers.unity.com/answers/407563/view.html
I think you want to use [velocity][1], not force.
[AddForce][2] is for applying a constant/varying force over time.
While you could work out the force you would need to apply for 1/60s (or whatever your physics simulation is running at) to get the required velocity, it'd be easier to just use velocity.
I'm pretty sure you'll be wanting [this][3] to solve the problem. I'm going to keep thinking on it for a more specific solution because this is a pretty interesting question :)
By the way: there will be times when it will be impossible to hit both with a fixed starting upwards velocity. Is that intended?
Or have I misunderstood the question and you actually mean to apply force throughout the simulation (which won't produce the parabola in your diagram) and we're looking at something more like a homing missile?
Edit: Also- is the second plate always at ground level? I think its solvable even if not, but it would probably simplify things a lot
[1]: http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-velocity.html
[2]: http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html
[3]: http://en.wikipedia.org/wiki/Equations_of_motionWed, 27 Feb 2013 12:48:05 GMTTarlius