Legacy GM Instance Deactivation Issue - Enemies Getting Stuck In Floor

RyanC

Member
Hi everyone,

I'm having some trouble deactivating my floor objects and was wondering if anyone can help?

I deactivate the obj_floor before I deactivate the enemies but the enemies are still getting stuck in the floor.
I think it's because the enemies bounding boxes could be overlapping the activation region, but sometimes the floor beneath them is not.

This is what I have every 7 steps in an alarm.

Code:
instance_deactivate_object(obj_PARENT_Collectable)
instance_deactivate_object(obj_PARENT_Enemy)
instance_deactivate_object(obj_level_scenery_PARENT)
instance_deactivate_object(obj_floor)


instance_activate_region(view_xview[0]-384,view_yview[0]-256,view_wview[0]+800,view_hview[0]+800,true)

alarm[11] = 7
 
The trick is to deactivate/reactivate a larger region for the blocks then the enemies. It's been a long time since I've run into this problem, but I'm fairly certain this will solve the issue.
 

RyanC

Member
The trick is to deactivate/reactivate a larger region for the blocks then the enemies. It's been a long time since I've run into this problem, but I'm fairly certain this will solve the issue.
That sounds like it will work, I'm fairly positive it's due to enemies being activated when there's no floor underneath, then the floor activates over them.
Anyone know how to do this, instance_activate_region does not allow for specific objects does it?

I'm currently having to use a system that gets the enemies out of the floor but it's using way too much CPU.
 

RangerX

Member
Indeed you can't specify things like that with activate region. You could activate everything then deactivate what's too far from view and/or specific objects under X conditions but then again, constant activation of everything could probably cost too much too. Anyhow, do I understand you have solid object based collisions? Do you stretch your collision objects in order to save some juice? This could also help your mobs getting into the ground because if your objects are only deactivated while out of view, a long block of collision will probably deactivate after the mobs that are on it.
What you could also do is to play certain tricks on your AI. What if gravity for them is 0 when you of view? I mean, you deliberately stop them from falling I mean. That could be a quite cheap solution.
 

RyanC

Member
I'm actually activating another region around the level builder that builds the level during game-play so deactivating everything out of view doesn't seem like a good choice.
There are also lots of objects that get created a 0,0 and just run code sometimes, so that would be another region I'd have to activate constantly.

My floor objects are 256x128 size and destructible, so there's no really big collision surfaces and yet the issue is still there.
I tried making it so all enemies out of a smaller region (which was basically the view size minus their bounding box's) just had:
x = xprevious
y = yprevious

But that didn't really work either.
 

RyanC

Member
So does anyone know how to activate different regions then?
I've done some more testing and it seems the issue is definitely due to the enemies overlapping the activation region before the floor objects beneath them do.
 

RangerX

Member
You cannot activate certain objects in a region. It's either an object or a region. Nobody answers because the dream solution you seem to want doesn't exist. You will have to adapt the game to the situation.
Its easy to tell when a mob is not visible on screen, modify its AI so its not sinking in the ground. Or have your collision deactivate themselves only when they at more than a certain distance from the view, etc. You will have to play tricks or adapt the game.
 
Top