2011-05-29 80 views
1

我得到這個錯誤:攪拌器的Python錯誤

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) 
+0

那麼你的問題是什麼? – orftz 2011-05-29 21:43:02

+0

我得到這個錯誤:回溯(最近一次調用最後一次): 文件「移動」,行1,在(模塊)NameError:名稱'GameLogic'未定義 – shaimaa 2011-05-29 23:27:09

回答

0

GameLogic是C擴展模塊。它只能在遊戲引擎中運行,當從Python遊戲邏輯控制器執行時,會有很多示例文件在線顯示如何完成此操作。