Problems getting object names

I have a scene with a blender with several objects, I would get the name of the object when the mouse is over one of them, setting the property of the empy object. Now I have a list of scene objects. What can I do?

import GameLogic
cont=GameLogic.getCurrentController()
obj=cont.getOwner()
print obj
objlist=GameLogic.getCurrentScene().getObjectList()
print objlist
sen=cont.getSensor('sensor')
if sen.isPositive():
    print objlist[0]
    PropName=.... #how to set this with the object name?
    print PropName
+3
source share
2 answers

To be useful to someone else, I answer my question. I did to set the sensor mouse overfor each object inside the scene and add a python script controller to set the property of the scene Empty object.

import GameLogic
import Rasterizer as r
r.showMouse(1)   #just in order to get the mouse visible within the game engine
print 'SetProperty.py\n'
cont=GameLogic.getCurrentController()
obj=cont.getOwner()
emptyOb = GameLogic.getCurrentScene().getObjectList()["OBEmpty"]
emptyOb.EmptyProp=obj
print 'object name, within emptyProp: ', emptyOb.EmptyProp
0
source

, SCA_MouseSensor hitObject, , . None KX_GameObject. , name ( ).

:

, , , , Blender Game Engine. , , Blender 2.59, , .

0

All Articles