This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I have created a procedurally generated map that essentially resembles infinite space. There is a boundary around the player and any unfilled cells get filled with tiles, such that when the player moves, this boundary space is checked and filled with tiles.

Naturally, this isn't optimal. I would like tiles to be deleted when they are not in view, so there isn't a constant memory overload.

I thought I could do this check at each process call, or I could create a custom Tile scene that is scripted to constantly check if its in the set boundary and, if it is not, delete itself.

It would be great to learn the best practice for this! I have also thought of using a Parallax background - will this give me the illusion of infinite space too?

Godot version 3.5.1
in Engine by (27 points)

1 Answer

+3 votes

The TileMap node should already be optimized for the behaviour you are trying to achieve.

Anyway, the same way you add tiles to the tilemap, you can remove tiles:

# Clears a cell
$TileMap.set_cellv(position, TileMap.INVALID_CELL)
by (294 points)

Awesome, thank you. So, as long as the tiles are not in the tilemap, the Godot engine will simply retain skeletal data for recreating that any non-visible tiles once they come into view again? That's how I would understand it as an optimisation.

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.