Crash when variable'd objects are ended

Confusing title, I know. Best way to describe the problem, though.

To solve the problem of incorrect (read: abysmal) tracking with added objects, I use a point-at-object script and some variables which contain the target objects (not just their names, I’m talking g.target = own here). But as soon as the object in question ends, and something’s tracking it, Blender crashes.

I’ve tried various things. It didn’t work when I told each object to clear its references just before its ending. And the try…except syntax doesn’t work either. Does anyone have any ideas?

g.target? are you using global variables here? that could explain the crash when you end the target object… try doing it without global variables?

Yeah, global variables. They’re the only solution I had found so far:

  • Simply tracking to an added object reeks with abysmal bugs.
  • Objects seem to blow up (script abort) if they look at a property of theirs that is another object (like own.target, and it’s an object). May be because I’m forced to init them with themselves first (own.target = own), I wouldn’t know.
    I have about half an idea to fix the second list item. But in case that doesn’t work, does anyone know how to clear the object reference from the global variable before it’s ended? It didn’t seem to work when I tried it.

maybe you could load the object into a list and then remove it from the list… or you could code some sort of break clause. maybe use logic like this… test if the object exists run the script and if it doesn’t exist stop. eg. if object exists: do blah
else: do something that involves not crashing?

I suggest trying to just get that part right first then including the tracking part.
… maybe you could write a script that gets activated only the objects end actuator and removes it from the global list of yours?

without posting your script it would be hard to figure out

It’s hard to say what the problem is exactly.

What kirado said sounds like a reasonable thing to try (although the fact that a ‘try-except’ block didn’t do the trick, kinda makes me doubt that even this would). The thing that would really help out here is an example.

Could you strip down the script to just the basic structure that actually causes the crash, and then upload the .blend?

I think it’s the best way to show us exactly what’s wrong in this case.

Okay, so apparently the reason the search-for-yourself-and-remove-the-reference method wasn’t working was because of a bad for loop…angry I really hate it when such things screw up big things.

That said, the crash-happy bug still exists. My problem is solved, but the bug isn’t fixed.

seriously without seeing a blend with the code in… it’s impossible to help you. Don’t get me wrong I’m not interested in stealing your script or project or anything… there could be other bugs… good luck with fixing it.