ObjectGroup within Object

I am currently creating a 2d top down game. The tilemap of my game is divided into rooms. I have implemented the rooms as Rectangle objects.
Within each room there are both tiles and enemies. Enemies are implemented as Tile objects. For the game to work I need to find both the tiles and enemies and add them to the room where they belong.

It is easy for me to find the tiles which belong to the room as I know the coordinates of the room.

However, when it comes to enemies I need to loop through all enemy objects and add each which is within the bounds of my room.

It would be useful if I could have an objectgroup within an object.

With the added functionality I would be able to have an objectgroup named “rooms”. Within the “rooms” objectgroup all the rooms are stored as objects.
Within each room object there is an “enemies” objectgroup that stores all enemies within the room. This makes access of enemies that belong to the room much faster.

I hope you understand what I mean, if not, I can provide further explanation.

One possible workaround to my problem would be to have a object layer for each room, and within that object layer I place the room rectangle object and all the enemy tile objects.

Nevermind, I think I got it :smiley:

I’m glad to hear you’ve found a way to solve your problem, but I just wanted to let you know that moving towards a hierarchical data format is certainly something I’d like to do in the future. This would include nesting of objects inside of other objects.