How to avoid overlapping sprites in Construct 3 when moving to one point? Like in Vampire Survivors

2 favourites
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Last I checked Vampire Survivors doesn't prevent overlapping/collisions, and it doesn't use physics libraries either. It "decollides" sprites at intervals. There are many ways to go about it, but a very simple way you can do similar is by checking overlap and using a separate bullet behavior for decollisions in addition to the constant bullet movement towards the player. You can observe this in Vampire survivors after death, to see the movement behavior when a lot of sprites get stacked up.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • i am building such a game at the moment. the way that i am doing it (with very little cpu) is to make the items solid, but ONLY when they are within 200px of the player character.

    this means that i save a HUGE amount on cpu usage, and i run at 120 frames with 150 enemies, bullets, and various other objects on-screen.

    another thing i did (i am proud of this) is only make items solid when they are close to a bullet. you would think that this is CPU-heavy, but it is the opposite and makes the game run really smooth.

    my game is not perfect by any means, but it's the best way that i have found to have so many enemies on screen while keeping FPS at 120, and CPU low.

  • oosyrag There are many different collision avoidance systems that can be used. So far I've never seen any info on what Vampire Survivors used although I know it was originally created in Phaser so it certainly had access to physics libraries.

    Looking at the gameplay it does look like physics to me, you can see pushing happening with the mobs when the faster enemies fly through them etc. and it looks too clean to be simple de-colliding.

    De-colliding without any area referencing is also not a great solution and just leads to chain reactions so saying it is simple is probably a bit misleading.

    Nevertheless it is fun to explore different approaches with and without physics.

  • R0J0hound Hello! Can you tell me if your example can be bound to deltatime? There are some controversial points and I don't know how to do it better. Thank you very much for what you do!

    P.S. Sorry to still torment you with my questions and requests, but you are a pro! I wanted to ask you how do you think it is possible to improve performance if you consider the logic for characters outside the screen differently?

  • MyXpandaZ calminthenight

    The simulation is rather basic so I can lead to instability.

    I'm not sure how you're moving the sprites toward the target, but it's better to set the velocity than setting the position, and better than that is to gradually change the velocity. In general that allows everything to be more stable. Another thing you can do is limit the max speed the objects can move. Another solution is making the push out less rigid. As is it pushes each pair out of each other completely in one go, but changing it so it only moves apart 25% of the way or lower will smooth things out more. Look for the js line that sets dist. There should be a /2 at the end. Change that to /10 to make the pushout softer.

    I probably need to revisit this to clean it up.

    Here's were I tweaked the example from last week but it deviated a fair bit as I was messing around with various ideas.

    https://www.dropbox.com/scl/fi/adgm5izhyk7indhjbqlz4/spatialGridJS2.c3p?rlkey=oafjw813djgai8x9pddbaq6ke&dl=1

    the file is not accessible, may I get a new link?

  • Fixed I think. Dropbox changed how it does links and it seems to break on this forum.

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