if cont.actuators['track_to'].object == None:

if cont.actuators['track_to'].object == None:

Such verification is not working for some reason.
How to describe the condition?

blender2.70a

What are you trying to call with “trackto.object”? Do you mean the target? Isn’t it called target? Maybe try this:

if cont.actuators['track_to'].target == None:

try


if not cont.actuators['track-to'].object:

Having ‘no’ object to track to might == “”, which is != None
Or something like that. One of the python gurus can probably explain it properly, but this is usually the better way to test if something is “Nothing”.

if cont.actuators[‘track_to’].object == None:

It turned out it works, the error was in the other :o

target

No

if not cont.actuators[‘track-to’].object:

Yes. So, too, it is possible.

If it’s not (sometimes actuators don’t like None type as input)

store a property, if it’s targeting the property is a game object, otherwise when you clear it,

replace it with the string “Empty”

this way, I use


if type(own['target']) is not str:

(if it’s not a string it will be a game object :D)

you can use this in conjunction with

if own['target].invalid:
    own['target']="Empty"

this way, if the object is deleted, it will not throw any errors.

The advantage to using “if not” is that it works in a more general way.

if x == None will only return True if x == None. If x=False, this will return False (as False != None).
if not x will return True if x=None, or if x=False, or if x=[], or if x={}.

if own['target].invalid:
own[‘target’]=“Empty”
this way, if the object is deleted, it will not throw any errors.

Interesting!

The advantage to using “if not” is that it works in a more general way.

Right. Thank you.