Entity does not exsist [EntityName]

Blitz3D Forums/Blitz3D Programming/Entity does not exsist [EntityName]

Rrtaya_Tsamsiyu(Posted 2015) [#1]
So, i'm having a problem with this simple program. Right now all it really does is test collisions.

Basically there's a square map, and spheres start out on either side and head toward each other. If they hit each other on the way through, one gets deleted.
Every now and then it will give me a Entity Doesn't Exist error at the line with EntityName, near the bottom of my code. It's especially a problem if there are a lot of objects existing at once.

Escape exits, R spawns another wave of spheres.


Any idea what is causing this?


videz(Posted 2015) [#2]
Apart from the error message you're getting, you should also see what line the cursor is located as that's your indication where you should check your code.


Matty(Posted 2015) [#3]
I can see what is happening from your code.

Imagine one tank is involved in two collisions during an update world with two different tanks.

When you get to the first tank involved you delete the collided tank.
then when you get to the second tank involved you get an entity doesn't exist because you've just deleted the original tank.

The simple solution to this is to use a flag instead of deleting the entity. When you want to remove the entity set the flag. Then after the loop has finished run through a second loop - as the last step, and remove all entities that have the flag set.

As an aside....most likely not relevant here but....With blitz you can get away with creating objects and deleting them on the fly no problems....if you ever decide to move to coding for mobile this will not work (not well anyway) because (in the case of Android) the garbage collector will kick in due to the creation and destruction of objects and cause your game to stutter. The solution to that is to not create or delete anything at all inside your main loop...


Rrtaya_Tsamsiyu(Posted 2015) [#4]
Thanks videz. i know what line it is, just didn't know what was causing it.

Thanks Matty, that makes sense. i'll make the change and test it again

Edit; Works now, thanks!


stayne(Posted 2015) [#5]
A bit off topic but anyway here's a tip: When you get a bug and B3D stops, click OK, hold shift and arrow to the right a few times. It will begin to highlight the line the cursor is on. Sometimes the cursor is hard to see.