Hi i am trying to make it so that if an object is in the world for a certain amount of acts it removes itself, or if a character (Sonic) runs against it for a certain amount of acts it gets removed. At the moment i am trying to use the canSee method but that requires you to be on the object, how can i do this to make it so that a counter runs if my character is one coordinate away from the object?
void remove()
{
if ( canSee(Sonic.class))
{
iceCounter = iceCounter+1;
}
else if ( !canSee(Sonic.class))
{
iceCounter = 0;
iceMelter = iceMelter++;
}
if ( canSee(Sonic.class) && iceCounter == 30 )
{
getWorld().removeObject(this);
iceCounter = 0;
}
if ( iceMelter == 100 )
{
getWorld().removeObjects(getWorld().getObjects(IceBrick.class));
}
}