The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I'm trying to make a Scramble style game which is a horizontal landscape scroller with a static character that can move independently up/down/left/right. I have made a tilemap which has the landscape but I don't know how to move (scroll right to left) the tiilemap while keeping the player positioned in the middle of the screen. The player should be able to collide with the landscape.

I can scroll the tilemap by putting a camera on the player and making the player move (position.x +=1) but the tilemap scrolling needs to be independent of the player moving.

Any help/suggestions with just pointing me in the direction of tackling this is really appreciated. I've tried experimenting with viewports etc for a few days and I'm completely stuck.

in Engine by (36 points)

Since posting this I have discovered that the tilemap can be scrolled(moved) using its transform. Is this the best way to go about the game type I'm designing?

1 Answer

+2 votes
Best answer

Instead of scrolling the tilemap, you could just have your character and camera constantly moving in the direction you want them to travel, as well as recording your player movements. Instead of having the camera focused on the player, have it focused on a separate Node2D, which will be the middle of your screen. You can also have a moving collision box around the camera to prevent the player from leaving the game screen.

The reason to do it this way, rather than by scrolling the tilemap, is that you'd also have to scroll every single other "non-moving" object in the game. It's much easier to just move the camera and player simultaneously.

by (449 points)
selected by

Thank you very much for replying. I've managed to get this working as you described.

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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.