Trying to optimize my platformer game

So I’m trying to make a platformer game where the player can switch between two different move sets. the way I did it is make it so there are 2 different platformer characters, and every time the player switches, the game deletes the current character and replaces it with the other one. the problem is that it makes the game extremely laggy since I need to check for collisions (spikes, crumbling platforms, etc) for both characters.

Is there a more optimal way of doing this? I’ve thought about maybe checking if each character exists and then putting the collision checks in sub-events, or making the game check for collisions only 10 times a second. but I don’t know how to do either of those things, so I need your help.

That shouldn’t make the game laggy. How are you checking for collisions? Can you provide a screen shot of the events?

"since I need to check for collisions for both characters"

The game gets especially laggy when the “Add” and “Divide” blocks are on the screen.

At first, a simple trick would be to add the condition “Trigger once while true” to all of your events.
Because right now, when the player is touching Add_Block for exemple, it is creating an object and deleting the other every frame (60 times per second !). With that condition, it’ll do it only once.

Edit : corrected

The collision with the add and divide blocks and actions shouldn’t have much of an impact, so my initial thoughts are that there is something else going on. Are there other events involving the Add and Divide blocks?

Also, you should have a trigger once on the Crumbling_Platform collision events.

That’s not correct, because it’s a different object that is created.

Only if the conditions will be met in sequential game frames. But for the events where a collision is checked, and then one of the objects deleted, there’s no point as it wont happen again in the immediate frames that follow. I suspect there’s an overhead cost (very slight) with a trigger once.

Indeed, you are right about the “different object created” .My bad

1 Like

the crumbling platforms stop working when I add a trigger once