For background, almost all of my sprites are about 2k resolution, I have a bunch of disabled events, I don’t have the best coding method (as long as it works). My game always crashes at a specific event. What should I do to fix the lag and prevent my game from crashing?
It just makes me sad that after all my hardwork and of those who helped me here end up not showing because of this constant crashing.
Gdevelop acts weird sometimes. You can check these;
→ If you resize a sprite in scene editor and change its animation with events, it will forget its size and resize itself to its original resolution. So you can resize a 2k image to 720x but it will return to 2k after some actions.
→ Same for scaling. Scale actions uses the objects original size. And big amount of big images can cause problems.
→ Check hitboxes. Gdevelop cant set them corretcly sometimes. Specially on high-res images.
→ You might have forgotten to put [Trigger Once] to a critical point and made it stuck in an endless loop.
→ You may be triggering false actions for wrong objects because of wrong grouping. For example you cant set opacity for some object types. You might triggering that action for an incompatible object or something like that.
→ Arrangement is an important thing. If you set an image to 50x somewhere in your event sheet, and set it 100x again after that point, it will never show 50x. It will always show 100x because its always the latest command to run. So you might triggering some actions that intersect the others.
→ Dont trigger events if its not required. Before appyling an effect to a sprite, check if its visible, opacity is greater than 0, is on screen, is on correct layer. Or before setting a variable to 100, check if its 100 or not. If its already 100, and dont try to make it 100 again and again. Limit these actions so your game will run smoother.
→ You can set resources to be always loaded on cache or sleep until required. Try to set these images correctly so it will run smoother.
→ I dont know if its common but one of my old projects crashed just because i installed a behavior. I didnt use it anywhere but still my project wasnt running properly. So existence of some behaviors can intersect others i guess.
As a general heads up, 2048x2048 is basically the maximum size a texture can be at all in the engine (and in many other engines).
This also takes up 2048x2048x4 (RGBA) bytes of memory from your GPU, or 16mb. That’s for a single frame. If you have 100 sprites visible in the scene, thats 1600 mb (1.6 gb) of your GPU memory, if you have an average of 3 frames each, thats 4.8gb of GPU memory.
If the sprite is added to your game at 2048x2048, it doesn’t matter if you resize it in the scene editor, it still takes up the full texture size in your GPU ram. If you don’t need it to be 2048x2048 you should modify it in your art tool and resize it down to the needed size.
I’ve said this on other posts, but even one of the the most graphically impressive 2D games on the market, Spiritfarer, keeps its largest sprite under 512x512. You really shouldn’t be going larger than that even in modern games.
Anything other than static backgrounds at 2048x2048 is going to be a waste of GPU resources, mostly.