0 votes

Hello! I've come up with the following problem: I was developing a Rogue-Like game on Godot, and while the result came up nicely, i've noticed that it is terribly optimized, and on some machines, it runs at 20 FPS or less, so i've been trying to use the Debugger, Profiler and Monitor tools to track down what is consuming more of the processor and whatnot.

I've noticed that, since i use a TileMap with tiles that i've created, each with its own collision shapes and exported to a .tres file, the number of collisions happening at each frame is quite large (on a smaller testing room i've had 66 simultaneous collision pairs happening, if my understanding of the Monitors tool is correct). That seems to be quite a waste processing power, and i've tried to remove the individual bits of Layer and Mask on every tile to check if the number diminishes, but it doesnt.

So my question is: is there a better way to do collision shapes using TileMaps? (Maybe i need to make invisible static bodies to go on top of a TileMap that doesnt have its own collisions?). Does that truly affect the performance of my game, or am I wrong to believe so and should look elsewhere in my project for flaws? Are Individual images less optimized than using a single, large image to draw a region as to the sprites of the tileset? Also, any tips on how to better optimize a game (especially games with such large maps, even if the main camera doesnt show all of it)?

Thanks in advance!

asked Dec 4, 2018 in Engine by jim (32 points)

Using single texture for entire tileset is more optimized than separate textures for entire tileset. Try to lower Cell Size in Project Settings/Physics (default is 128, try 64 or 32), it might help performace. If your performace still is not good enough you can even try to disable tile physics if they are outside of screen by adding VisibilityNotifier2D / VisibilityEnabler2D node to each tile before you make tile set. Hope it helps.

1 Answer

+1 vote

Hi,
Bit late to the show but in case anyone else lands here:
Assuming most or all of your tile collision shapes are square and fill the entire tile I made a little script that optimises them by merging collision shapes thereby reducing the number of shapes, see Here

answered Jul 7, 2019 by Ratty (39 points)
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.