Make game run smoother?

How do I make the game run smoother.
So as I’m playing galaxy ball its good at first but then I notice stutters or lag how do i reduce this will to code a script and btw idk how to use batch groups lol

Try deleting unnecessary files and scripts.

you can go through all of your scripts and look for things that can cause stuttering after a while.
eg: too much items in memory or in the scene, making arrays every update, long forloops or just any loop in general).

if you spawn for example bullets in a scene, delete them via script if they are alive for too long. to make sure that the count of currently active bullets stays as low as it can be.

Try to get your “update” sections of your scripts as small and lightweight as possible. these parts run every frame and the smaller they are, the faster it’s done and the smoother your game can be.

It can also be that there are too many entities in the scene that are colliding with each other. imagine you have 100 spheres with colliders on them and you make them bounce. Then the Physics engine needs to do a lot of calculations. even more if you have a script on those spheres that checks for the tag of the object they are colliding with. it’s these things that you need to look for and try to change as much as possible.

mhmm cough cough @DevPlex01 added too many entitites and Im pretty sure we need to look through the scripts to see what we need and dont need.And we could just make one script that runs the whole game which would be easier and kinda more complicated

Okay. But all I added were the things needed. Which is a lot of things. Plus I’m thinking of adding a Main Menu.

Maybe you can also use the profiler in PlayCanvas to see where some of the problems came from?

1 Like

hmm how do I use that?

plus we need to lower the mb in galaxyball

Instead of immidiately pressing the “play” button in the editor, I think you also need to check the “profiler” option.

lowering the mb for a game can be done in multiple different ways:

  • Optimizing the code to do the same things with less memory
  • checking if all your images are a power of two and their size is according to their purpose (Don’t have an icon of an arrow in 4K if you only use it as a tiny thing, somewhere in the background, where no one will see it.) Just try to make them lower in size to safe some room.
  • try co compress sounds in another format if possible
  • try to combine textures together (i mean in the different channels of a texture -> you can make a texture that consists of 4 greyscale textures, each in a different channel, this way you only have to load in one)
  • if working with 3D, optimize your models. delete poly’s that aren’t needed for the sillhouette to be recognizable. make low poly versions of your models, believe me, a lot of players don’t mind or don’t see it at all. if you use a cone for example, try to use as little polys for it as possible and ask some people if they think it looks okay still. if you add a normal map to it to make it look smooth, it’s often fine to use a low poly model. it will be smaller in size for the build, and faster to load in, and nobody will see the difference. try to balance optimization with quality.

Thnx Iĺl look into this