!is_empty() at line 1616 of panda/src/pgraph/ [SOLVED]

I’m working through teaching my AI how to shoot, and I’ve run into a surprising little problem. I get the following error:

!is_empty() at line 1616 of panda/src/pgraph/nodePath.cxx

at seemingly random points in my programs execution, and the trace back leads to code that has always been reliable, and has been executed multiple times in the program before the point where the error pops up. The error always occurs when calling getPos() with a reference node supplied.

I don’t fully understand what the error means, and I definitely don’t understand what it only pops up sometimes and not others.

Can anyone give me some insight on how I might solve this problem?

I’m running panda 1.6.2, if that helps.

It means the NodePath that you are calling getPos() on is empty, which usually means you have previously called removeNode() on that NodePath.

This sort of error can be caused from any number of mistakes. One common mistake is failing to stop a task when a model is removed.

David

I think that’s exactly what’s happening. I was looking at some other stuff and I noticed that the error gets thrown when one of my automated weapons gets destroyed. The AI task for the automated weapon is probably still running after it’s been destroyed. Giving each of these automated weapons a unique ID to name their tasks with would be a real pain in the butt, which makes removing the task a little tricky for me. I seem to remember something about taskMgr.add() calls returning an object that can be used to remove the task, which would work great, but I don’t recall how that works or where I saw it.

Okay, I found it in the manual. Just had to read it more closely. Thanks, David.