Lancer
Member
|
Remove Object from World
Hi,
I've searched on how to remove an object from the world and found this.
https://www.esenthel.com/forum/showthrea...from+world
It says I could use a command like
But I could not find anything about "ObjMemb"
Is there any other way to remove it without having to return "false" in update function?
|
|
07-26-2019 08:06 PM |
|
RedcrowProd
Member
|
RE: Remove Object from World
if its an object created from the game.world you can use this:
ObjMap& remove ( Int i ); // remove i-th object from container
ObjMap& removeId (C UID &obj_id); // remove object from container by its ID
ObjMap& removeObj(C TYPE *data ); // remove object from container by its memory address
once you create your world you can populate an ObjMap container, and easely remove it from there when you want.
if would still suggest that return false in the update is a little clearer, but its up to you.
(This post was last modified: 07-26-2019 10:37 PM by RedcrowProd.)
|
|
07-26-2019 10:35 PM |
|
Lancer
Member
|
RE: Remove Object from World
Im worried, if I just remove it from the ObjMap itself, it won't be properly removed from the world?
|
|
07-27-2019 12:08 AM |
|
Esenthel
Administrator
|
RE: Remove Object from World
Those ObjMap methods will remove objects properly
|
|
07-27-2019 02:21 AM |
|
Lancer
Member
|
RE: Remove Object from World
Is it safe removing the object from the ObjMap while in update function ?
|
|
07-27-2019 10:33 AM |
|
Esenthel
Administrator
|
RE: Remove Object from World
It's dangerous only if you remove object during the update for the object itself. (Obj.update)
But State update is safe.
|
|
07-27-2019 02:05 PM |
|