User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

Thread: Questions about bullet hell optimizations: Movement and collision

  1. #1
    Clicker Fusion 2.5 (Steam)

    Join Date
    Aug 2021
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Questions about bullet hell optimizations: Movement and collision

    I'm making a bullet hell game, so there's going to be plenty of bullets on screen, but i start running into frame drops much earlier than your average shooter game.
    I control bullets by giving them Alterable Values for angle, speed, X and Y. Use cos sin functions to update the X and Y Alterable Values based on the angle and speed ones and the physical X and Y positions are rounds of the X and Y Alterables.
    For collisions i have the bullets spawn an active the shape of a square and have it deleted next frame.

    Is there any way to optimize any of this, i was thinking if testing distance between bullets and player for collisions instead of testing if the player's hitbox overlaps the bullet's hitbox would be more efficient.

  2. #2
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2015
    Location
    Australia
    Posts
    245
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fuzzbearplush View Post
    For collisions i have the bullets spawn an active the shape of a square and have it deleted next frame.
    Do you mean every bullet on screen is creating a new object to test for collisions - then destroying it every single frame tick? That *could* be a reason for slowdown, but without seeing an MFA file (or profiling if you have Fusion 2.5) it's hard to say what's going on exactly.

    Instead of creating and destroying an object for every bullet, you could change the animation to the size of the hitbox you want, check for overlap, then revert it.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleUniversal Windows Platform Export ModuleSWF Export Module

    Join Date
    Jun 2014
    Posts
    86
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ^This

    Spawning an active at the sight of a bullet is going to result in effectively creating dozens of actives on every frame. Either follow the above advice, or have a pool of collision actives that you create at the start of a frame & reuse (frankly, you should do the bullets this way also if you aren't already). Creating & destroying actives is a quite heavy operation in Fusion, & especially if being done every frame.

    If you aren't doing this already, I'd also recommend to only check for overlap type collisions between "proximate" objects.

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    2,683
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    Creating objects can be relatively expensive when done a lot in a short space of time, so that's probably part of the problem. Marbenx's solution is worth trying. Or you could try just using the same square object that you're using now, but instead of creating and destroying it, you just create it once at start of frame, then move it onscreen and offscreen again. You could potentially reuse the same single detector object for every bullet. Just keep moving it to wherever you need to check collisions in that moment.

  5. #5
    Clicker Fusion 2.5Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    zip2kx's Avatar
    Join Date
    Jun 2015
    Posts
    874
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Why do you use a separate object to text collision? Your bullet objects should be able to do by itself.
    If you have a collider, use one and move it around by linking it to the bullets fixed ID, its more efficient than creating new ones.
    You could also add a separate animation of the bullet with a frame of the collider detector, then in a fast loop, switch to it, check collision and switch back the animation.

  6. #6
    Clicker Fusion 2.5 (Steam)

    Join Date
    Aug 2021
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by marbenx View Post
    Do you mean every bullet on screen is creating a new object to test for collisions - then destroying it every single frame tick? That *could* be a reason for slowdown, but without seeing an MFA file (or profiling if you have Fusion 2.5) it's hard to say what's going on exactly.

    Instead of creating and destroying an object for every bullet, you could change the animation to the size of the hitbox you want, check for overlap, then revert it.
    Upon some investigations, i found out some bullets stay for a while even when leaving the screen. How big is the auto-delete frame? Or maybe is there something that prevents it (Destroy object if far away from frame is checked)? It has behaviors applied to it, but it's just a single function to change the rotation of the sprite.

    The method you mentioned for collision test optimization sounds good, until i remember that i use animation frames to store different sprites for the bullets.
    Was thinking i should just make the bullets test how far away the player is and subtract player and bullet hitbox radius, if < 0 then get hit, this would have the benefit of circular hitboxes but idk the performance. I could only test bullets that are close to the player

  7. #7
    Clicker Fusion 2.5 (Steam)

    Join Date
    Aug 2021
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zip2kx View Post
    Why do you use a separate object to text collision? Your bullet objects should be able to do by itself.
    If you have a collider, use one and move it around by linking it to the bullets fixed ID, its more efficient than creating new ones.
    You could also add a separate animation of the bullet with a frame of the collider detector, then in a fast loop, switch to it, check collision and switch back the animation.
    You've got a point, i can just move a single hitbox to each bullet, i didn't think of that.
    I don't test for collision with the actual bullet because that's pretty rough gameplay-wise

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleUniversal Windows Platform Export ModuleSWF Export Module

    Join Date
    Jun 2014
    Posts
    86
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fuzzbearplush View Post
    Upon some investigations, i found out some bullets stay for a while even when leaving the screen. How big is the auto-delete frame? Or maybe is there something that prevents it (Destroy object if far away from frame is checked)? It has behaviors applied to it, but it's just a single function to change the rotation of the sprite.
    How were you checking for out-of-window bullets? If you were just using "is out of play area" or some other event that just compares bullet coordinates, those conditions by themselves are only checked once per frame, so you could've been missing bullets that are moving faster than 1 pixel per frame & as a result avoid being detected as out of the frame for a while. You should remove bullets in a loop of some kind.

    I'm making a shoot em up too (not a bullet hell type shooter though), so I'm just interested how other developers of shooters go about it

  9. #9
    Clicker Fusion 2.5 (Steam)

    Join Date
    Aug 2021
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by YesNoYes View Post
    How were you checking for out-of-window bullets? If you were just using "is out of play area" or some other event that just compares bullet coordinates, those conditions by themselves are only checked once per frame, so you could've been missing bullets that are moving faster than 1 pixel per frame & as a result avoid being detected as out of the frame for a while. You should remove bullets in a loop of some kind.

    I'm making a shoot em up too (not a bullet hell type shooter though), so I'm just interested how other developers of shooters go about it
    Huh, i just leave them be because don't they get auto deleted by default? There's an option called 'Destroy object if far away from frame' in active's properties

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleUniversal Windows Platform Export ModuleSWF Export Module

    Join Date
    Jun 2014
    Posts
    86
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fuzzbearplush View Post
    Huh, i just leave them be because don't they get auto deleted by default? There's an option called 'Destroy object if far away from frame' in active's properties
    They should do, but as it's an application property, I have no idea how often it triggers or how exactly it gets "deleted" (are actives with running behaviours all destroyed? etc..). I don't really understand how it works so I just set this to "no" & handle it myself.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Super Bombardier - Bullet Hell Shmup
    By rosse119 in forum WIP & Released Games & Apps
    Replies: 43
    Last Post: 20th April 2018, 09:49 AM
  2. Replies: 5
    Last Post: 14th July 2017, 08:18 PM
  3. How would you go about making an endless bullet hell game?
    By yemibox51 in forum Developer Services
    Replies: 0
    Last Post: 16th November 2016, 09:27 PM
  4. If bullet overlaps a certain object, damage the shooter of the bullet
    By StardustSpeedman in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 10th September 2012, 02:43 PM
  5. Bullet collision animation never ending
    By Pixels in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 21st September 2007, 05:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •