- Home /
How to arc rigidbody2D velocity to hit target gameObject
I'm building a 2D game with a catapult. I can't figure out how to make a projectile with a rigidbody arc to hit the target. I have looked around and every other solution is too complicated or just doesn't work. Any Ideas or pages I could look at? Like is there a simple equation ( In javascript code please ) that can solve my problem?
Answer by darthbator · Jun 11, 2014 at 01:10 AM
You'll want to solve with the Bezier Curve equation.
I'm not a super mathematician (I barely like math) so I can't really explain the how and why of the equation. But that's the method you can use to find a suitable curve to a destination in 2D or 3D space.
Ill look into it..its not a perfect solution but ill give it a shot
$$anonymous$$ost of the tweening libraries out there (like iTween) have a function to do exactly what you're asking for if you don't care about solving the issue yourself.
Alternatively you can open up their code and take a look at how they are solving it if you're interested in only that part of their package.
Your answer
Follow this Question
Related Questions
Not understanding how rigidbody2D.AddForce works 0 Answers
How to assign Rigidbody2d to a player using Javascript 1 Answer
What is wrong with this catapult script? 1 Answer
Trajectory of a projectile formula. Does anyone know maths? 5 Answers
How to create a 2D parabolic trajectory prediction line with javascript? 1 Answer