1

我收到此错误:

Traceback(最近一次调用最后一次):
文件“movement”,第 1 行,在(模块)NameError:名称“GameLogic”未定义

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)
4

1 回答 1

0

GameLogic 是 C 扩展模块。它只会在游戏引擎中运行,当从 python 游戏逻辑控制器执行时,网上有许多示例文件展示了这是如何完成的。

于 2011-08-20T21:43:52.830 回答