我已经看到许多关于如何获取对象位置的问题,但我需要相反的问题。我正在制作一个游戏,并且知道某个owner.worldPosition中存在一个对象,因此需要获取该对象的游戏属性。怎么办呢?另外,请使用代码,而不要使用逻辑块。
答案 0 :(得分:0)
您使用python控制器运行脚本。您从中获得的所有者
cont = bge.logic.getCurrentController()
own = cont.owner
是运行脚本的对象。请注意,game object与您通过bpy
获得的对象的属性不同。
如果要访问其他对象,则可以通过game scene中的对象列表来访问它们。
sce = bge.logic.getCurrentScene()
for ob in sce.objects:
print(" ", ob.name, ob.worldPosition)
print(sce['otherObj'].worldPosition)