我已经安装了Blender 2.73,并查看了几个教程,以及Python的Blender API文档,它们向我展示了如何使用bge来移动对象,但是在运行脚本时,我从Blender上得到了几个错误。
NameError: name 'bge' is not defined
所以我导入了bge文件,但是它给了我一个ImportError
ImportError: No module named 'bge'
我已经查看了我的搅拌机文件,并没有找到一个bge文件,如果我可以手动导入或移动该文件。然后我下载了Blender的rar文件,以检查bge,但是那里没有运气。所以我在网上寻找一个可能的答案,如果是个人下载,或者我错过了什么,但我找不到任何可以解决我的问题的东西。
我能够运行其他python模块,如bpy,似乎只有bge在某种意义上是缺失的。我正在运行Windows 7,在Blender之前已经安装了Python3.4。
我正在使用的代码试图旋转基本立方体。
Controller = bge.logic.getCurrentController()
Owner = Controller.owner
Move = Controller.actuators['Spin']
PressLeft = Controller.sensors['SpinLeft']
PressRight = Controller.sensors['SpinRight']
Speed = Move.dRot[1]
if PressLeft.positive:
Speed = Speed + 0.5
Move.dRot = [0.0, Speed, 0.0]
Controller.activate(Move)
elif PressRight.positive:
Speed = Speed - 0.5
Move.dRot = [0.0, Speed, 0.0]
是的,我知道我的代码不符合推荐的设置。
发布于 2015-01-11 02:02:59
bge
模块用于混合器游戏引擎,只有在游戏引擎运行时才可用,不能从搅拌器的python控制台访问它。
要在游戏引擎中运行python代码,需要将python控制器连接到传感器并启动游戏引擎。
https://stackoverflow.com/questions/27882285
复制相似问题