Blender-Python错误
我遇到了这个错误:
错误追踪(最近的调用在最前面):
文件 "movement",第 1 行,在 (模块) 中
名称错误:'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)
1 个回答
0
GameLogic 是一个用 C 语言写的扩展模块。它只能在游戏引擎内部运行,当你通过 Python 的游戏逻辑控制器来执行时,就能使用它。网上有很多示例文件,教你怎么做到这一点。