Help with Cameras / Layers

Im working on game 2d platformer with one level and as you complete that level there are obstacles added to it, I’m planning on adding these obstacles through layers. For example, if you beat the level for you would replay that level but a layer would be added which has the obstacles stored inside it (Sorry if you can’t understand what I’m saying). But the problem is when I place the obstacles and assign them to a layer when I start the game those objects are stuck to the screen and moving with the camera instead of staying where they should be. I hope you guys can help me, this has been bugging me for the past couple of days

2 Likes

I’m not sure if you can do that by layers (someone more experienced will be able to confirm) but you could do that a few other ways I think. You could “create object” when the level is over and basically populate your map with the new obstacles by using the create object and x / y position of object, or I think the easier way is to put the new obstacles on the map into an object group, and then hide the object group to begin with, then show the object group on the next level. Alternatively you could just copy the whole scene (right click copy) and paste it into a new scene, then arrange the new obstacles in the new scene. That’s the easiest way I think. Having each level on a new scene would be easier to work with too from a level design point of view.

1 Like

You can absolutely do this by layers.

As an example for platforms:

Just have a for each event for the objects in question, and say if layer isn’t visible disable platform behavior.

If layer is visible, enable the behavior.

Make sure the for each has a trigger once.

1 Like

If I understood you correctly, your problem is that the additional layer is fixed in place, doesn’t give a fork about camera movement.

You have to set up the camera movement for the other layers too, because the position of the camera in each layer is independent from the camera position in the other layers. That is, if you don’t tell the camera to follow player movement (or whatever) in the additional layers, it just won’t do it and those layers will look just the same as the initial camera position.

When I’m back home I’ll show you a screenshot of my camera/layer events if nobody else has given you an example :blush:

1 Like

@mixten

Here is an example of how you make the camera move through other layers according to its movement on the base layer.

The last two lines of the second event are the ones you want, I think:

Change the X position of camera (layer: “YourSecondLayer”) = CameraX()

Change the Y position of camera (layer: “YourSecondLayer”) = CameraY()

The other layers with formulas that multiply by 0.x are for parallax layers

2 Likes

I see what you’re trying to say but I need the obstacles to be completely Still

If you look at this video it’s not what I would like

ezgif-7-442f60ef583b
Also here is a video. The Grey box should be under the brick with the coin on top but it’s stuck on my screen

Make sure everything is on the layer it’s meant to be, then put a screen of your camera events


Heres a pic of my events

As far as I know that formula doesn’t mean anything. Set the cameraX on L2 to “CameraX()” and the cameraY on L2 to “CameraY()”, if you want the camera to move through L2 at the same rate that it moves through the base layer.

If you don’t set it at the same rate, what you get is a parallax layer.

2 Likes