This project has moved. For the latest updates, please go here.


May 28, 2010 at 12:26 AM
Edited May 29, 2010 at 2:03 AM

I'm new to Farseer physics and I've decided I want to create a catapult.  I've already figured out how to move around an object using the keyboard to apply velocity to objects and how to detect their collisions and pretty much everything I need.  What I can't seem to figure how is how to launch something from a location using an angle.  I was looking over Andy's website and almost exactly what I'm trying to do was in his game "Boss Launcher".  Anyone know where to start or how to help point me in the right direction for this?






Well more like a canon or something but same concept.


            float Angle = MathHelper.WrapAngle(_Fish.GetAngle());
            Vector2 Velocity = new Vector2((float)(Math.Sin(Angle) * Thrust), (float)Math.Cos(Angle) * Thrust);
            _Fish.LinearVelocity += Velocity;



I've come up with this from the research I've done but my biggest problem is that on certain angles it goes in a completely wrong direction.




*EDIT* - again


            float Angle = MathHelper.WrapAngle(_Fish.GetAngle());
            Vector2 Velocity = new Vector2((float)Math.Cos(Angle) * Thrust, (float)(Math.Sin(Angle) * Thrust));
            _Fish.LinearVelocity += Velocity;
its amazing what happens when you switch the cos and sin....that fixed it.

May 29, 2010 at 8:57 PM

That is right. The last one you made is how you compose a vector from an angle and a length (Thrust in your case).