I’m new to this forum and I’ve searched a bit to see if I could find a solution to my problem but I can’t.
So I started this thread.
I wanted to try to make an object move (just a simple scene with a cube and a plane), but when I use the GameLogic module the console tells me that it there is no module named GameLogic.
I saw a bit of the code on a site and I wanted to try to make the cube move by events of W, S, A and D keys.
Here is my code:
# Importing modules import Blender as B import GameLogic import GameKeys obj = B.Object.Get('Cube') # Store 'Cube' in variable obj # These variables is what they used on one of those sites I've seen KX_NO_INPUTSTATUS = 0 KX_JUSTACTIVATED = 1 KX_ACTIVATE = 2 KX_JUSTRELEASED co = GameLogic.getCurrentController() # Get controller sensor.co.getSensor('Keyboard') keylist = sensor.getPressedKeys() for key in keylist: # Get key event if key == KX_JUSTACTIVATED: if key == GameKeys.WKEY:# move -0.5 on Y-axis on W pressed obj.LocY -= 0.5 if key == GameKeys.SKEY: # move 0.5 on Y-axis on S pressed obj.LocY += 0.5 if key == GameKeys.AKEY: # move -0.5 on X-axis on A pressed obj.LocX -= 0.5 if key == GameKeys.DKEY: # move 0.5 on X-axis on D pressed obj.LocX += 0.5
I’ve also made a sensor and a controller, because I read something about that aswell.
but I still get the error “No module named GameLogic”
It might be that this code makes no sense at all, but I just want to see if it works this way .
- blender 2.44
- Python 2.5
- Windows Vista (I don’t know if this might affect the problem)
Thank you for your time.