Handle collisions better to improve performance

I’m have a game that has “apply force” and “collisions” in various objects. The game runs partially well, but often shows some performance issues, somewhat like a horizontal wiggle in everything thats moving.
I’m trying to reduce resouce usage with tutorials, using sub-events when I can, and trying to avoid as many collisions as possible (like using “object is in Y position” instead of "object is in colision with something).

How can I do that, improve my fps? Is there any code trick or events, conditions or actions that can help me?

There is a performance profiler that you can try, to identify your performance issues.
You will find it in the debugger window.

This link has some tips to performance improvement.


1 Like

@Bouh , how can we edit and add content to the document?

Create an account on the wiki, and start here:

I already tried these two links. I double checked everything, It seems the game fps is 60 all around, I realized im not getting fps drops in the whole scene, only the objects that are moving seems wobbly sometimes.

I had the same issue in other game, but i fixed it puting an instant force in the whole group of enemies instead of a permanent force with trigger once in each individual enemy. but in this case it didnt work

Wobbly collisions can sometimes be fixed using “dead zones”. For instance don’t apply collision detection on an object that hasn’t moved more than 5 pixels since last frame. This works great for jerky cameras too.

Collision optimizations can sometimes be improved by only applying collision detection to a subset of objects. For instance select only the nearest object to the player, or select only the objects within X distance of the player and only apply collision detection to them. This is very case dependent, but can sometimes be effective enough.

Nice tip, my game is a runner, so I just need to check colisions of the closest object. I’ll defintely try to find a way to do that

I tried that, now my game is only checking collisions of the closest object, and only the objects which X position is lower than 500. Nothing changed about the wobbly movement, I tried to record but in the recording seems like its an fps drop, but it isnt. its more like all the objects moved 3 pixels back and forth ocasionally.

I also want to state that after some tries (when you die and reset the scene three or four times) this problem almost vanishes, but is very noticeable in the first runs

Maybe I’m looking for a collision performance problem, and the real problem is the “apply force” actions… I really don’t know.

I use a lot of number of object checks, so if Number of Objects >= 1, then it checks. It seems to work the best out of everything I’ve tried.