I have this platformer game, where you have zombies and they just go back and forth on a platform right, typical platformer. Now the algorythm behind it is that I have these invisible triggers, which on collision with a zombie, mirror the zombie and make it move in the opposite direction.
The problem is that when a level is big enough (9000x2500 for example) and I have many of those triggers (20 for ex.) the game starts to lag when I built in on iPad using cocoonJS. In the event sheet I have
"ZOMBIE on collision with 'goright' >>> mirror zombie, set direction to RIGHT"
"ZOMBIE on collision with 'goleft' >>> NOTmirrored zombie, set direction to LEFT"
My question is, how exactly does the "on collision" work in the algorythm? I've tested the game and in the levels which don't lag, if I add some triggers somewhere on the map, it starts to lag. My thoughts were that each of every zombie checks for every trigger there is on the map per tick - so when those triggers accumulate, the zombies have to check for all of them and the game slows down. So the fact that those triggers have an effect is there. But I still wanted to make sure if that's how "on collision" works, since it's a one time event. If it was "when overlapping" then I'd be sure that it is checked per tick, but in "on collision" case I'm not sure so I wanted to make sure and thus made this long ass post for which I apologize :D
Also, if that's the case, do you guys have any idea how to go around this? I though of making it so that the zombies check only in the certain area around them, so they don't reach every trigger on the map but i'm not sure how to implement that yet.
Anyway, all the feedback is appreciated as always, sorry again for the length, I just wanted to share my thoughts on it and state the problem clearly :D