too many invisible triggers? lag!

0 favourites
  • 10 posts
From the Asset Store
Game Triggers is as versatile as a Swiss army knife, and will be a great resource for any type of game you're creating.
  • Hi guys,

    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

  • It doesn't sound like that should be making it slow. If you disable the events, does it go faster?

  • It might be worth adding a nearest/furthest event. It sounds like you zombies are checking all the points they could collide and not just the ones there near.

    Might also be worth adding in some local variables on the zombie and the collision point. If zombie.variable = 1 collides with trigger.variable = 1 then run the action.

    Ether way you shouldn't be receiving a lower framerate due to checks.

    My final piece of advice would be to send in a capx to the lovely people here and have them look through your code just to make sure you haven't left in "every tick behaviors" that don't need to be there.

    There could even be a solution in using the family behaviors but I don't have any experience there.

    Let me know how you get on as this subject has intrigued me.

  • Maybe you should be looking at how you are moving these zombies rather than the triggers...

    20 triggers is not much, but it may be enough to tip the performance over the edge if something is not optimised elsewhere...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Might I also suggest that on such a large layout that you place invisible trigger blocks so that when the player hits the blocks the nearest zombies are spawned. Then there is no checking until the zombies are spawned. And you aren't wasting ticks checking for things that the player can't even see at the time.

  • (we are both working on this)

    this is image of all zombie events

    there is spawner, when player is within range it spawns zombie

    zombie moves left or right and changes direction when hitting special triggers.

  • Here is a Cap file, if anyone could look at and see if we do something very wrong that would be great, thanks in advance

    dl.dropboxusercontent.com/u/1248743/WashingtonVSZombies-fps.capx

  • For what it's worth it runs brilliantly on Chrome.

    Your problem might, and use the term jokingly, come from the fact that at any given time the game is handling 500+ objects.

    This is pretty easy to cut down, firstly you can use a library layer to store all the objects your current layout isn't using.

    The number of enemies could also be decreased, I was completely swarmed out of the gate and would never have got past the second group if I hadn't realised that touching your health bar clears the screen of enemies (A feature I imagine won't make it to the final build!)

    Maybe trim the particle effects a little bit? When your triggering it for every attack and reaction and can imagine it adding up.

    Overall though I really liked the game! Nice spin on the whole Abe Lincoln Vampire hunter deal!

  • few things I noticed in a quick look over it,

    many of your background sprites have collisions enabled and there is no need for them to have

    your zombie movement change triggers could be much smaller and still be as effective (I still think a trigger once action with variables as triggers would be better here)

    many of your weapon sprites have upto eight points in their collision "boxes" most would be fine with 3

    particles are a performance killer..maybe make a sprite to look same and use that instead...

    This did run at 60 fps on chrome for me though...

  • yeah, it lags when built on iPad using cocoonJS, on Chrome it runs ok, thanks for the massive feedback guys, we'll try everything you've mentioned so far and get back to you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)