# Spaceship steering.

This topic is 4997 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello. Im trying to create a cool steering for my spaceship dogfighting game. The problem is i it was very long ago i studied physics in school. I remember basic stuff like acceleration and forces. But how do you make it fun and cool? Hmm :-) As it is now its really only a freelook camera with dampening on, which is the results of my sorry attempts. Does anyone know a good resource/(open source game) for making a fun way of controlling a spaceship in fast paced battle? I am looking for stuff like taking the ships roll into accout when going forward to produce a turn, or looping, etc. It dosn't have to be realistic, as long as its fun. This stuff was harder than i tought to do. Thanks in advance!

##### Share on other sites
I have a simple system for that kind of controls. I'll post it once I get back home.

##### Share on other sites
here is in essence the source code.

Vector xShipPos(0, 0, 0);Vector xShipSide(-1, 0, 0);Vector xShipUp(0, 1, 0);Vector xShipDir(0, 0, 1);float fShipSpeed = 0.0f;;float fShipPitch = 0.0f;float fShipYaw   = 0.0f;float fShipRoll  = 0.0f;void ShipMove(float dt){	xShipPos += xShipDir * fShipSpeed * dt;	if (xShipPos.y < 10.0f)		xShipPos.y = 10.0f;		if (xShipPos.y > 1000.0f)		xShipPos.y = 1000.0f;}void ShipPitch(float dt){	Quaternion Q;	Q.FromRotation(xShipSide, fShipPitch * dt);	xShipUp   = xShipUp   * Q;	xShipDir  = xShipDir  * Q;}void ShipYaw(float dt){	Quaternion Q;	Q.FromRotation(xShipUp, fShipYaw * dt);	xShipSide = xShipSide * Q;	xShipDir  = xShipDir  * Q;}void ShipRoll(float dt){	Quaternion Q;	Q.FromRotation(xShipDir, fShipRoll * dt);	xShipSide = xShipSide * Q;	xShipUp   = xShipUp   * Q;}void ShipUpdate(float dt){	xShipSide = xShipUp.Cross(xShipDir);	float fAccel = KeyPressed('W') - KeyPressed('S');	float fPitch = (mousey - 0.5f) * 2.0f;	float fYaw   = KeyPressed('A') - KeyPressed('D');	float fRoll  = (mousex - 0.5f) * 2.0f;	fShipSpeed = Clamp(fShipSpeed + fAccel * 0.04f, -20.0f, 20.0f);	fShipPitch    = fPitch * 0.4f;	fShipYaw      = fYaw   * 0.2f;	fShipRoll     = fRoll  * 0.6f;	ShipPitch(dt);	ShipYaw  (dt);	ShipRoll (dt);	ShipMove (dt);	xShipUp.Normalise();	xShipSide = xShipUp.Cross(xShipDir);	xShipSide.Normalise();	xShipDir = xShipSide.Cross(xShipUp);	xShipDir.Normalise();}

I think it's self explanatory. It just takes a set of inputs and converts it into orientations and accelerations.

you can find the full demo here.

keys are mouse, and a, w, s, d.

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633399
• Total Posts
3011663
• ### Who's Online (See full list)

There are no registered users currently online

×