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

So I am doing a map generator, when the player reaches certain x position a tilemap is loaded and another is distroyed I use the following code to do this:

func _on_createa2_body_entered(body):
    total_distance = total_distance + 1024
    var new_tile = TileMap1.instance()
    new_tile.position.x = total_distance
    #Here I add the instance to the tree

func _on_destroya2_body_entered(body):
    var arreglo = tiles.pop_front()
    #Here I remove the node

For some reason the games slowdown, I read into object pooling but some dev a time ago said that was not necessary in godot so I dont know what to do.

in Engine by (22 points)
edited by

1 Answer

0 votes

What do you expect you'll get as an answer here? If someone said "pooling is not needed" he maybe meant "godot has good memory management" he didn't meant "instancing new objects won't take any cpu".

In 60 FPS environment, there is only 15 ms to load your tilemap without framedrop (as you probably know). If your tilemap is big or has many objects you have to expect some cpu usage.

But.. you allways have options for sure, at first read this:

But a simpler solution may be reducing your tilemap sizes (make more chunks). Or preload them when player is inactive (reading text, mixing potions, opening inventory and so on) if possible.

by (206 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 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.