rstralberg
Member
|
[SOLVED] How do I temporary remove object
I have the need for removing an object from the world, but not for good.
I will keep it in memory. Just want it invisible (and not colliding either).
Just temporary as I need to restore it later. Couldn't find anything on that in the docs.
Any hints on that?
(This post was last modified: 07-08-2015 09:43 AM by rstralberg.)
|
|
07-06-2015 11:23 PM |
|
Zervox
Member
|
RE: How do I temporary remove object
can't really think of anything not involving separate extra container workarounds or adding extra variables- functions for the object that would disable the physics object and disabling the drawing in drawPrepare etc.
|
|
07-07-2015 03:34 AM |
|
Esenthel
Administrator
|
RE: How do I temporary remove object
Hi,
You'd need to make a custom parameter something like "bool removed" and then handle the logic based on that.
|
|
07-07-2015 03:42 AM |
|
3DRaddict
Member
|
RE: How do I temporary remove object
|
|
07-07-2015 06:56 AM |
|
rstralberg
Member
|
RE: How do I temporary remove object
Okay. Thanks guys.
You lead me in the right direction.
Here is what works for me.
Code:
class myItem : Game.Item
{
// ... code not relevant here
// ...
// ...
private:
//
// --- pretend we are not existing
//
Bool _removed = false;
void remove()
{
_removed = true;
actor.active(false);
}
void restore()
{
_removed = false;
actor.active(true);
}
Bool is_removed() C
{
return _removed;
}
public:
UInt drawPrepare()
{
if( _removed )
{
// make us invisble
uint draw_mask=0xFFFFFFFF;
FlagDisable(draw_mask, IndexToFlag(Body)); // clear head draw group flag
SetDrawMask(draw_mask);
super.drawPrepare(); // call default drawing after setting the mask
SetDrawMask(); // reset default mask
}
else
{
super.drawPrepare();
}
}
void drawShadow()
{
if( _removed )
{
// prevent shadows
}
else
{
super.drawShadow();
}
}
}
(This post was last modified: 07-07-2015 12:38 PM by rstralberg.)
|
|
07-07-2015 12:04 PM |
|