Game Development Reference
In-Depth Information
Object removal
As bullets have a very short lifespan within the sandbox, it's necessary to remove them
once they've collided. Calling
Sandbox.RemoveObject
will destroy the passed-in
sandbox object from the sandbox.
Note
Destroying objects happens at the end of the sandbox's update loop. Objects can still be ref-
erenced until the sandbox's update call has finished.
The
RemoveObject
function requires passing both the sandbox instance as well as the
sandbox objects to delete.
Sandbox.RemoveObject(sandbox, sandboxObject);