Deleting an object based on it's physics id (In game)

Hello once again!
today i was wondering if there is a way to delete an object based on its physics id. I have a list of ids and I need to delete a variable amount of them.
while the game is running.
Thank you all once again! :smiley:

You can loop through all objects and end the one with the matching physics id.

Where do you get the physics ID from?

obj.getPhysicsId() Thank you once again monster!

you know every Python object has an id already:


id(anyPythonObject)

Usually it is not the best idea to store such ids. Better store the references to the objects.

The reason is simple:

  • with references you have direct access without searching
  • the reference dies with the object (e.g. after scene switch)