How do I remove barriers in rooms when enemies are all killed

I have a room checker that checks if it’s colliding with a player and enemies, if all enemies are dead but the player is still in collision with the collider then the gate in the room is removed.

Now here’s the dilemma, I have rooms that have different number of gates, some have 2 and some have 4, now if it’s just a room with 1 gate then I simply give my room checker a point that spawns the gate. The other problem is that I have different sprites for vertical gates and horizontal gates.

Here is an example just so you guys can picture it out.

So what I mean by horizontal gates are the ones on the right and left, and vertical for upper and lower ones.

If you have different sprites for each gate type then you could put all of the gates into a group and use the group name.

Do you want all of the gates deleted or just specific ones?

Just the gates in which room the player is in

You could start identifying the room colliders by using an object variable on each (like roomId) set to the number of the room. Then put for each gate (both horizontal and vertical) an object variable equal to the roomId of the collider they are located. As Keith suggested put both gates in a group and when you check if the collider has no enemies delete the group with the object variable equal to the roomId of the collider…

Hope that makes sense…

It sounds like you’re using a object to tell if a player is in the room. If so, then you could use the same object to pick the gates and if they’re in a group, you can delete the gates with 1 action

If player is in collision with collider
(picks the collider )
If gates are in collision with collider
(picks the gates)
Action: delete gates

You need you include your check for enemies. I don’t know if you have more enemies in other rooms of the scene.

1 Like

How would I spawn the gates if a player entered a room though? do I use points or other objects?

I thought the gates would’ve been added when you add the rooms either at design time or with events. Are you using scenes created through the designer or adding rooms from an external layout like a room builder?

You could use points on the collider.

No no, you see when a players enters the room the collider inside the room checks if the player has entered and if theres enemies inside, and then the gates spawns, and like I said some rooms will have 4 entrances/exits and some have 2, which is why I’m doubtful if I should use points on the room checker and instead opt for invisible objects to spawn them.

1 Like