User Tag List

Results 1 to 9 of 9

Thread: Destroy one of two cloned colliding objects based on flags

  1. #1
    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)

    Join Date
    May 2014
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Destroy one of two cloned colliding objects based on flags

    This is a really dumb problem to be having - I'm sure the solution is going to look stupidly obvious in retrospect, but I'm stumped.

    I have two kinds of bullets, Player and Enemy bullets. Both have the Bullet qualifier, and each have Good and Bad qualifiers respectively. They also both have a flag on them, which is by default on for Enemy bullets and off for Player bullets. I want player bullets to destroy enemy bullets. Of course, when player bullets collide with enemy bullets, the enemy bullet is destroyed, easy enough. Problem is, I have a 'counter' mechanic where players can send Enemy bullets flying back towards the enemy that fired them. When an Enemy bullet is countered, that flag on that bullet is toggled.

    How do I make a countered Enemy bullet also destroy Enemy bullets, as though it were a Player bullet? I can't add or remove qualifiers at runtime, I can't check the qualifier's flag on one of a colliding object but not the other if they share that qualifier, and even without qualifiers I still can't check the flag against only one of a cloned object and not the other (much less delete the right one of those two objects).

    Any advice? Thanks in advance.

  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
    124
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I was just recently trying to figure out a way to figure out events with two of the same objects - this is the solution that I found works for me;
    collisioncheck.png

    When the two bullets collide it runs a quick loop on both of the objects, which you can use to further scope down.

    Here's an example where one bullet is randomly picked and a flag is set for it to be the counter bullet
    counterbullet.mfa

  3. #3
    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)

    Join Date
    May 2014
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tip. So that works very elegantly (and tells me that I clearly don't understand for each object loops - I guess that only loops through the Active objects in the collision condition's callback? else it would destroy every bullet but the countered one as soon as any of them collide. TIL), but it has the same logic problem I've been grappling with. When two normal enemy bullets collide, they shouldn't both be destroyed (or they'd wipe themselves out before any could reach the player). I basically need "if two enemy bullets collide, only if one of them has this flag toggled, destroy the other one."

    Your solution is super close - is there some small key I'm missing to get that last step?

  4. #4
    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
    124
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by north View Post
    I guess that only loops through the Active objects in the collision condition's callback? else it would destroy every bullet but the countered one as soon as any of them collide. TIL
    Correct!

    Quote Originally Posted by north View Post
    I basically need "if two enemy bullets collide, only if one of them has this flag toggled, destroy the other one."
    Ahh, sorry I misunderstood you originally. The easiest way I can think of doing this would be to
    - create a new 'countered' bullet (i.e. a different active object) when the enemy bullet is countered, at the at the X/Y position of the old bullet
    - destroy the old enemy bullet

    Basically, creating a new object and destroying an old one to take its place.

  5. #5
    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)

    Join Date
    May 2014
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by marbenx View Post
    Correct!

    Ahh, sorry I misunderstood you originally. The easiest way I can think of doing this would be to [...]
    Mannn, I was really hoping you weren't gonna say that. It sucks if that's my only viable option, it'll require gutting and reworking a lot of existing code. Drat.

    Thanks for the help (and for teaching me something new and useful in the process). Guess I'll get to work lol

  6. #6
    Clicker Fusion 2.5

    Join Date
    Jun 2006
    Posts
    850
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried another, working solution, without new objects:

    If two bullets collide, run a loop for Each "bullet" object - this will actually run twice (as two bullets collide), once for each of the colliding bullet. You can obtain fixed IDs of both colliding actives and then do the check, as you will be able to select them with their fixed ID.

    Something like:

    On each one of "bullets" //which will be executed just twice, if two bullets collide
    +FixedID1 >0 - Set FixedID2 to Bullet(Fixed)
    On each one of "bullets"
    +FixedID1 = 0 - Set FixedID1 to Bullet(Fixed)

    After the collision, you will have both Fixed IDs in FixedID1 and FixedID2 counters.

    Then its just comparison using variables.

  7. #7
    Clicker Fusion 2.5

    Join Date
    Jun 2006
    Posts
    850
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Attaching an example of the code using the approach above (i.e. finding out colliding fixed IDs and then checking whether one of those is "Countered"). Uses just one active, looping and values. The order of the On loop events is important but I assume you are familiar with that.

    I also added handling in case two "countered" bullets collide, then nothings happens.

    Just run it and watch all objects collide with no consequence. Then click on any of them to make them "countered", and from that point it will destroy the normal ones upon collision.

    countered1.mfa

  8. #8
    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)

    Join Date
    May 2014
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Blizna View Post
    Attaching an example of the code using the approach above (i.e. finding out colliding fixed IDs and then checking whether one of those is "Countered"). Uses just one active, looping and values. The order of the On loop events is important but I assume you are familiar with that.

    I also added handling in case two "countered" bullets collide, then nothings happens.

    Just run it and watch all objects collide with no consequence. Then click on any of them to make them "countered", and from that point it will destroy the normal ones upon collision.
    I read over the code in your example, and it makes sense, and it works! Blizna, you are a godsend. Super clever solution, and I don't have to dismantle my existing system to implement it. Thank you so much!!

  9. #9
    Clicker Fusion 2.5

    Join Date
    Jun 2006
    Posts
    850
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by north View Post
    I read over the code in your example, and it makes sense, and it works! Blizna, you are a godsend. Super clever solution, and I don't have to dismantle my existing system to implement it. Thank you so much!!
    Happy to help and glad to hear it will save you some effort

Similar Threads

  1. Making cloned objects match animation
    By Warmachine in forum Fusion 2.5
    Replies: 2
    Last Post: 23rd September 2014, 11:47 AM
  2. Toggling flags based on multiple conditions...
    By OlivettiFever in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 20th December 2012, 12:19 AM
  3. Click Detection on Cloned Objects?
    By apsharkey in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 5th February 2012, 04:26 PM
  4. 2 Dynamic PMO objects colliding?
    By Krim in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 5th June 2011, 07:55 PM
  5. Detecting collisions without the objects colliding
    By Mantoid in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 18th November 2006, 09:28 PM

Posting Permissions

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