How do I create collisions between enemies without using behaviors?

0 favourites
  • 7 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • I was creating a game similar to Vampire Survivors, where countless enemies are generated across the screen...

    The problem is that if I don't define any type of collision between them, they end up overlapping too much.

    The obvious solution is to create a collision event between enemies, the problem is that if I use behaviors, the FPS goes from 144 to 0 when pass 500 enemies created.

    Could someone who has created a game with a massive number of objects colliding with each other tell me what the solution to this problem is?

    I found many ways to create collision in construct3 but none of them were tested in cases where there are many objects, I really don't know what to do 😞

  • I've done this before using multiple bullet behaviors on the same object.

    One behavior heads towards the player.

    The second bullet behavior, using the enemy object in a family, can be set to -

    On family overlap with enemy (or within x distance) - set family bullet behavior angle away from enemy, and set enemy bullet behavior angle from family. Use a high speed, and a high deceleration. You can even set the speed inverse to their distance to each other if you want, so that they repulse each other harder the closer they are to each other. This doesn't necessarily prevent overlap, but neither do monsters in vampire survivors.

    This is more akin to steering or boids style maneuvering.

    I would also recommend updating steering forces only every x seconds instead of every tick, for performance reasons. You can also see this in action in vampire survivors after you die.

    Regarding performance for massive amounts of enemies, you might notice there actually aren't thousands on screen at a time in vampire survivors. Try counting them. The enemies (and xp drops for that matter) are culled when offscreen and xp is combined.

  • I've done this before using multiple bullet behaviors on the same object.

    One behavior heads towards the player.

    The second bullet behavior, using the enemy object in a family, can be set to -

    On family overlap with enemy (or within x distance) - set family bullet behavior angle away from enemy, and set enemy bullet behavior angle from family. Use a high speed, and a high deceleration. You can even set the speed inverse to their distance to each other if you want, so that they repulse each other harder the closer they are to each other. This doesn't necessarily prevent overlap, but neither do monsters in vampire survivors.

    This is more akin to steering or boids style maneuvering.

    I would also recommend updating steering forces only every x seconds instead of every tick, for performance reasons. You can also see this in action in vampire survivors after you die.

    Regarding performance for massive amounts of enemies, you might notice there actually aren't thousands on screen at a time in vampire survivors. Try counting them. The enemies (and xp drops for that matter) are culled when offscreen and xp is combined.

    Thank you very much, I will see what I can do

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Weirdly, Phyiscs behavior works really well with a large number of moving objects. Here is someone else's demo, with 500+ zombies I'm getting 144 fps and only 15% cpu utilization on my PC.

    dropbox.com/scl/fi/b8w45zomhay2o9lfmrqxb/ZombieAiNoOverlapingV3.c3p

  • construct.net/en/forum/construct-3/how-do-i-8/move-enemies-vampire-survivors-171628

    It may help

    Thanks, I solved the problem using Physics and I even posted the game if you want to see it: gingercatstudio.itch.io/rogue-survivor-generic

  • Weirdly, Phyiscs behavior works really well with a large number of moving objects. Here is someone else's demo, with 500+ zombies I'm getting 144 fps and only 15% cpu utilization on my PC.

    https://www.dropbox.com/scl/fi/b8w45zomhay2o9lfmrqxb/ZombieAiNoOverlapingV3.c3p?rlkey=mcca4hu4xyjyuuzjva6blg848&st=d5x9kid1&dl=0

    Thanks, I solved the problem using Physics and I even posted the game if you want to see it: gingercatstudio.itch.io/rogue-survivor-generic

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