I was trying to make my object get the object and objects that where hit by near sensor using this code
g=GameLogic
c=g.getCurrentController()
o=c.getOwner()
near=c.getSensor("sensor")
x=near.getHitObjectList()
print x
then I watched the console and it said [] and if I put two object near it said [,]
is´t it supposed to have OBCube printed in between that
I recently started learning python so I don´t know if it was me who did something wrong or if it´s a bug or if there is some other solution to this so any help at all would be apriciated
getHitObjectList() is returning a list of the objects. What your expecting is the name of the objects. To get that you could use something like:
for obj in x:
print obj.name
I realize your new to python, but using names that are meaningful will help you later. Hopefully your not a sight typist. Anyway, a good name would be nearList or nearObjects instead of x.
The nice thing about having it return the objects, by the way, is that you can directly make changes to those objects.
Like: