This project has moved and is read-only. For the latest updates, please go here.

Space ship physics help

Topics: User Forum
Nov 3, 2013 at 3:48 PM
I have been coding a space sim for a few months now, had been using box2d with some minor additions I did to it, but I switched to farseerphysics as soon as I stumbled across it.

And I'm sure I'm not doing things the recommended way, I'm still learning farseerphysics.
So here is my current problem, and my first post on here, hopefully not the only one lol (so bare with me.)

I'm trying to make a space ship that controls and acts between a simulation and an arcade game. But I'm having problems trying to get it to move as desired.

This is how I have the space ship set up, a single image, with various thrusters. A few thrusters at the bottom for forward movement, and a few on the side for rotation. each ship is different.
Up till now for rotational thrusters, i have been using a separate thruster type that applies a value to the ship's angle property. What I want to do, is get rid of this code, and figure out somehow to get the ship to physically turn when a thruster is being applied at an angle. but somehow be compatible with forward thrusters, etc.
But box2d/farseerphysics doesn't seem to affect the physical rotation anywhere in the forces/impulse/torque code.

how forward thrusters are done right now:
for each ship update I am going through each thruster; calculating the thruster's force and center according to the ship's body. I am then using these values to the ship's body's ApplyForce(forces, center).

Forces for the thruster is calculated like this: each thruster has a maximum power, each ship can control the percentage of this power. I'm rotating a point from 0,0 using cos/sin, using the power as the distance to move the point out, at the angle the thruster is facing from the ship's center. this point now becomes the forces I apply to the body at the location the thruster is placed on the ship.

if anyone has any ideas, suggestions, I'd like to hear them. not much out there on the webs about this certain situation.

also i don't know if this is the right place to post this, don't seem to find a farseerphysics forum anywhere.
Nov 9, 2013 at 12:48 PM
You should be able to use ApplyForce.
A easy thing to miss, is the Force and the Point is based off of the word, not the body.
So you'll want it something like:
Body.ApplyForce(Body.GetWorldPoint(new Vector2(0f, 100f)), Body.GetWorldPoint(ThrusterPosition));
(Farseer Physics 3.5)

Or you could, create a body for each of your thrusters. Than use joints to connect them to the ship. and apply force directly to the thruster.