I am making my first game in the BGE, it is about hovercar “races” i am trying to get my cars to go forward at the moment and after reading the api docs i figured out a good choice for this purpose would be using applyImpulse()
however, i am not quite getting what coordinate system it uses
here is how i think works:
(x and y axis are local to the object with zeroes at the object’s origin)
and here is my code stripped to its bare minimum
def thruster( control ): #control is a list of 4 boolean values representing forward, back, left and right, respectively
thrust = 0.1
turn = 0.25
impulsePoint = mathutils.Vector((0,-1,0))
impulseDirection = mathutils.Vector((0,1,0))
if control[2]:
impulsePoint.x += turn
if control[3]:
impulsePoint.x -= turn
if control[0]:
obj.applyImpulse(impulsePoint,impulseDirection * thrust, 1)
return
This code does not quite do what i expect.
instead, it seems like the impulse direction and point might be global on global coordinates, with just the point being offset by the object’s position.
here are my results :
EDIT: in the GIF you can see that the cube moves along three different roughly linear paths, instead of taking a turn.
any help will be appreciated. thank in advance!