Nateguana
Nateguana

Reputation: 69

blender get object from position

I have seen many questions asked on how to get the position of an object, but I need the opposite. I am making a game and know there is one object at a certain owner.worldPosition, and I need to get the object's game properties. How could this be done? Also, please use code and not logic bricks.

Upvotes: 1

Views: 783

Answers (1)

sambler
sambler

Reputation: 7079

You use a python controller to run your script. The owner that you get from

cont = bge.logic.getCurrentController()
own = cont.owner

is the object that is running the script. Note that a game object does not have the same properties as the object you get through bpy.

If you want to access other objects, you can access them through the object list in the game scene.

sce = bge.logic.getCurrentScene()
for ob in sce.objects:
    print("   ", ob.name, ob.worldPosition)

print(sce['otherObj'].worldPosition)

Upvotes: 0

Related Questions