我知道有办法找出某个对象在BGE中的组。
在API中,它表示您使用KX_GameObject(SCA_IObject)
和groupObject
来获取对象所在的组,并使用groupMembers
来获取组中所有对象的列表。我尝试了许多不同的方法让它工作,但我总是得到一个错误。有人可以告诉我该怎么做吗?
这是代码。
import bge
from bge import logic
import bpy
cont = bge.logic.getCurrentController()
own = cont.owner
scene = logic.getCurrentScene()
objs = scene.objects
print(objs)
#here I tried to get the list of members in the group
group = bpy.data.groups["group"]
print(group.groupMembers)
#ERROR: 'Group' object has no attribute 'groupMembers'
#here I tried to get the group object is in
cube = bpy.data.objects["Cube"]
print(cube.groupObject)
#ERROR: 'Object' object has no attribute 'groupObject'
感谢。