Dman1791
Dman1791

Reputation: 1

Some instances not appearing when switching rooms [GMS2]

I'm a bit new to GMS2 and am having a bit of a problem. In the current state of my game, you start in a useless room that only exists to initialize global variables and a persistent object. This room then switches to an actual level. All of this occurs in the creation code of the first room:

globalVars();
instance_create_depth(-2*global.tile_size, -2*global.tile_size, 0, OBJ_UTIL_manager);
room_goto(2);

Upon switching rooms, only some of the instances appear. In particular, only objects without a parent or with one certain parent appear. Objects with another type of parent do not appear. They are present in the room builder. They DO exist, but are invisible.

The same room, if moved to the top of the room queue and therefore being the first room created, works just fine as long as I add the above global variable initialization and manager object creation. Is there anything special that must be done when switching rooms to make things visible?

This is how the room appears in the editor: http://prntscr.com/lg2x3w

Compared to how it appears upon being switched to: http://prntscr.com/lg2wdg

Upvotes: 0

Views: 1659

Answers (1)

Mohamed_DKD
Mohamed_DKD

Reputation: 1

I do not know the full detail of the problem, but I did have a similar issue, so I can tell you a solution without actually knowing what went wrong, but anyways hope it helps.

Firstly, use the instance_create_layer instead of instance_create_depth and make sure that these layers where you create your objects exist in both the first "fake" room and the actual room.

secondly, make sure you do not have any code that change the depth/layer in the create event. [again I do not know why this could cause an issue, but it did cause an issue to me, so maybe you have the same issue/solution]

Upvotes: 0

Related Questions