1

i get this error :

Traceback (most recent call last):
File "movement", line 1, in (module) NameError: name 'GameLogic' is not defined

import GameLogic

cont = GameLogic.getCurrentController()

fwd = cont.sensors['forword']
bck = cont.sensors['backword']
lft = cont.sensors['left']
rit = cont .sensors['right']

move = cont.actuators['move']

speed = [0, 0, 0]
rot = [0, 0, 0]


if fwd.positive:

# speed[0] 0 mean the movement will be according tot he x axis 
# speed[1] 1 mean according to the y axis and 2 for z axis

   speed[0] = 0.7

elif bck.positive:
    speed[0] = -0.7


if lft.positive:
    rot[0] = 0.1

elif rit.positive:
    rot[0] = -0.1


move.uselocalDloc = true
move.uselocDrot = false

move.dloc = speed
move.drot = rot

cont.activate(move)
Andrew White
  • 52,720
  • 19
  • 113
  • 137
shaimaa
  • 37
  • 1
  • 3
  • 9

1 Answers1

0

GameLogic is C extension module. It will only run within the game engine, when executed from a python game logic controller, there are many example files online showing how this is done.

ideasman42
  • 42,413
  • 44
  • 197
  • 320