Near-Python bug???

I was trying to make my object get the object and objects that where hit by near sensor using this code

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

thanks in advance

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:

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.

for obj in x: = - 10

Will change the health property, if it had one.

thanks that really helped alot

I was wondering if you could get their position too

and then make all of them use a formula that get their distance
where it compare position of character with it own

so I can then know which one is the closest one and make the character track to it

and does anyone know how to get the object name through getHitObject

any help would be apriciated

pos = obj.getPosition()

Here is the game engine reference:

there was a new function to calculate the dist. I can’t remember the name. But you can do this:

a = posA[0]+posB[0]
b = posA[1]+posB[1]
c = posA[2]+posB[2]
dist = sqrt(aa+bb+c*c)
If you want to compare you can skip the sqrt().

and does anyone know how to get the object name through getHitObject

That’s what those lines of code I put up were for. The name of the object is