Space Game flight control setup questions

Hi all,

I’m trying to set up some flight controls for a spaceship. Basically I’m trying to duplicate the way the Vipers move in the new Battlestar Galactica series.

I’m using the Linear and Angular Velocity values for “thruster” movements (rotation and translation of the craft), but when I try to use Linear velocity for the main engine (which should only accelerate the craft), it doesn’t work as expected for anything but the initial heading the craft is in when I start the game.

Any help’d be much appreciated.


Check out my game UFO, is this the kind of movement your trying for?

Do you have the little “L” buttton pushed to make sure it is using the local orientation?

Will check out your game Killer.

Yup, though that’s honestly how it behaves, as if it’s stuck in the global instead of the local orientation. Double and triplechecked to make sure I had L set.


I’m having the same problem. Looks like a bug. Certainly a showstopper for this type of game.

edit: Well, I guess I can get by using Force. Submitted a bug report anyway.

Okay, I’ve got the flight controls working more or less the way I want, and now I’m trying to figure out something else.

How do I make it so I set a particular Linear Velocity with a keypress, and then with that same keypress set the Linear Velocity to 0 (turning on and off a main engine).


The easiest way is to use properties. The logic is as follows:

If key “w” is pressed, increase “go” by 1. (go=0 by default)
If “go” = 1, apply thrust.
If “go” = 2, “go” = 0 (so it goes back to off and will toggle).

Easier way:
if W is pressed:
bool go assign to !go
if go == True apply thrust

Hm, still working on the on/off functionality, just have to get the syntax right I think. Much thanks to both of you!

My next question is weapons. I’m looking at Social’s FPS template, and one I don’t understand much of it, and two, from what I do understand, it seems to be an instant-hit projectile, is this correct? I’d like to make projectiles with a fixed velocity, and I’m not entirely sure how. The addObject actuator seems to have sometimes random results. Searches have revealed little though I would think this would be a popular topic.

Edit: Solved!


Alrighty, next question - trying to figure out how to get the ship to move in two directions in once.

W and S control my pitch, A and D the roll, yet I can only get the ship to pitch OR roll, not both.

Edit: Solved!


Well, got a new question:

How do I use the result for getAngularVelocity?

If I wanted to assign the y value specifically to a variable, for example.

Alternately, is there a way to make an object roll faster and faster the longer you hold down a key, so that you can tap it for a minor movement and hold it for faster movement?


Maybe this post will meet with more success than the last 3…

What am I doing wrong here? This code is supposed to reset the speed property to 0 after I release the key, however it does not.

import GameLogic
controller = GameLogic.getCurrentController()
own = controller.getOwner()

act = controller.getActuator("actMotion")
pitch_fwd = controller.getSensor("fwd")
pitch_bwd = controller.getSensor("bwd")

#if up is pressed
if pitch_fwd.isPositive():
	own.speed -= 0.1
	own.speed == 0

#if down is pressed
if pitch_bwd.isPositive():
	own.speed += 0.1
	own.speed == 0



Okay I’ve gotten help before from y’all, so I’ll keep asking my questions. If I’m not being specific enough or there’s something causing my questions to be ignored, please by all means tell me.

I’m trying to make it so that if you tap the w a s d keys you get a slight correction in that direction. If you hold them down though it’ll roll or pitch the vehicle using a faster speed.

The print statements are there to see what’s going on, I haven’t been able to make “above” return a value of 1 however, though the “below” one seems to.

Here’s the code I have:

import GameLogic

controller = GameLogic.getCurrentController()
owner = controller.getOwner()

motion = controller.getActuator("actMotion")
fwd = controller.getSensor("fwd")
bwd = controller.getSensor("bwd")
left = controller.getSensor("left")
right = controller.getSensor("right")
engine = controller.getSensor("e_key")

xRotAction = 0
yRotAction = 0

mainSpeed = 0
linSpeed = 0.5
rotSpeed = 0.2
rotFastSpeed = 1

print ("above %i" % xRotAction)

if xRotAction == 1:
	xrot = rotFastSpeed * (fwd.isPositive() - bwd.isPositive())
	yrot = rotFastSpeed * (right.isPositive() - left.isPositive())
	xrot = rotSpeed * (fwd.isPositive() - bwd.isPositive())
	yrot = rotSpeed * (right.isPositive() - left.isPositive())

if xrot or yrot != 0:
	xRotAction += 1
	yRotAction += 1

print ("below %i" % xRotAction)

motion.setAngularVelocity(xrot, yrot, 0, 1)

Thanks in advance.