just do it like this code:

...
ptr_remove(ent);
ent = NULL;


development 3d game is interesting!