Hi there, folks!
I’m learning BGE, and I’m puzzled by what seems like a simple problem.
I was following the tutorials from Blender Cookie on setting up a basic game, but I can’t seem to make my little character turn to the left, nor to the right without exploding.
I’ve included my blend file with the script in it, just in case you don’t have time to open the blend, the script goes something like this:
import bge
from math import pi
def main():
cont = bge.logic.getCurrentController()
player = cont.owner
keyboard = bge.logic.keyboard
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.UPARROWKEY]:
player.applyMovement((0, factor, 0), True)
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.DOWNARROWKEY]:
player.applyMovement((0, -factor, 0), True)
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.LEFTARROWKEY]:
player.applyRotation((0, 0, pi/128), True)
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.RIGHTARROWKEY]:
player.applyRotation((0, 0, -pi/128), True)
main()
When the object I am running this script on not dynamic, or rigid body, it turns beautifully. When I set it to either of those two, it flips wildly in more than one axis. Can anyone give me a hint?
Thanks!
-Murphy