0 votes

I’m making a game which is a clone of Scramble. I’m using a tile map to hold the landscape graphics and using a camera to move across the landscape horizontally by adding +1 to the camera’s x position. This works fine so far - I get a nice horizontal scrolling effect.

When it comes to the UFO section (UFOs move in a figure 8 motion towards the player but in line with the landscape motion) )this is (several) sprites which move on a path by changing the x and y position using an array of Vector2 values.

The problem is that the UFO sprite is moving whereas the tile map isn’t and I find that the path of the UFO isn’t sync’d with the landscape (the landscape is static but appears to move via the camera position change), even with just moving the sprite 1 pixel left it’s appearing to move faster and isn't aligned to the landscape which is how it should be.

How can I make it appear that the UFO sprite and the tile map is moving at the same rate. In the old days you would physically scroll both the landscape and the sprites which would keep them in sync. If you moved your landscape left 1 pixel and your sprite left 1 pixel, they would be in sync. My landscape is technically static and the sprite is being moved left.

Any thoughts on how I can simulate the UFO sprite moving inline with the landscape (when I'm using a camera to make the landscape appear to move but it's actually static)?

Apologies for the rather awkward way of asking, any pointers or suggestions are really appreciated, I'm not looking for actual code just a pointer on what I should change.

asked Jul 9 in Engine by Mison (21 points)

1 Answer

0 votes

one option is to make the ufo a child of the tilemap or camera so that and then when do figure 8 use position instead of global_position and it will move automatically globally with the camera and locally in figure 8

answered Jul 9 by rakkarage (805 points)

https://gotm.io/henry-software/pixelleveltest/
example sprites being panned and zoomed with tile map

Thanks very much for your reply. I don't understand how making the sprite a child (of the tilemap or camera) will change the movement?

I'm using local position on the sprite's code which updates its own position

Can you explain a little bit more - thank you so much :)

sorry if i misunderstood but if you move parent child will come along...
if you want something to move in sync with something else then you can make it a child of the think that is moving and it will be in sync

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.