Post

in-depth thread: optimizing GDScript performance from ~83ms to ~9ms in a scene our tower defense game Rift Riff, made in Godot, with 1000 enemies. ๐Ÿงต๐Ÿ‘‡๐Ÿผ #gamedev #godotengine

(note before I start: it was too much work to profile each optimization and this thread already took 3 hours to make (literally ๐Ÿ˜…) so instead I opted to start each optimization with plusses, and more plusses == bigger performance gains. you'll just have to trust me the gains are as stated ๐Ÿ˜.)

+ we changed the enemy from extending a CharacterBody2D to a RigidBody2D. the character body offers a funky mix between code-controlled and physics controlled movement, but it turned out that this only costs extra for no gains.

++ we removed all String and StringName operations from _process(). enemies have directional move animations and we used to construct the names of those animations on the fly every time. now, we cache them on _ready() per direction. (the code diff of this was messy but here's how we cache them)