4

I am a newb at GameMaker. I have a 2D map which you can move around. I want to add pins to the map, such that when the map moves, the pins stay in the same position relative to the map. By default, the map will move, while the pins remain stationary.

I have tried creating a sub-layer of instances on my map instance layer, but the depth of the sub-layer is always greater than the parent layer. I have tried overriding the depth, but it gives me a warning suggesting unpredictable results.

enter image description here

enter image description here

I have searched the internet, but all I could find was overkill code which I am hoping is not necessary. (And none of those suggestions directly addressed my question.)

How can I make it so that my pins move around with the map? I would like to avoid using code for something so simple.

Evorlor
  • 5,793
  • 9
  • 55
  • 99
  • I think this depends on how you move the map, and how the map is build up. It is possible to have multiple instance layers at different depths, depending on their order. They don't need to be a child of a different instance. These instance layers should move alongside the other instances on the map. – Steven Feb 18 '22 at 07:44

1 Answers1

0

This does not directly answer the question, as it uses code. So hopefully a better answer without using code comes along.

Add to the Begin Step Event:

mapStartingX = inst_map.x;
mapStartingY = inst_map.y;

Add to the End Step Event:

xOffset = mapStartingX - inst_map.x;
yOffset = mapStartingY - inst_map.y;
x -= xOffset;
y -= yOffset;

I really hope this answer becomes obsolete. GameMaker is a widely used game engine and supposedly beginner friendly without code - I can't imaging they are missing this basic functionality.

Evorlor
  • 5,793
  • 9
  • 55
  • 99