getHitObject() returns blank?

hello!

my getHitObject() returns blanks in the console…

I have a near sensor connected to a script, but “print near.getHitObject()” (with near = cont.getSensor etc before) says first None when it’s too far away and that’s fine but when it comes closer it returns nothing but a blank row.

Any ideas?

It’s an object, so it doesn’t print anything. Use print near.getHitObject().name

You would need to put print near.getHitObject().getName() unless name is a property.

You would need to put print near.getHitObject().getName() unless name is a property.

name is a property of every object. You can also use the getName() function, which returns the name property. That’s really my bad, because the name property isn’t read only and it would be pretty easy to accidently change it using that method. getName() returns a copy and is a lot safer.

a thousand and one thanks.