User Tag List

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 26

Thread: [problem] weird loop behaviours

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Vilhjalmr's Avatar
    Join Date
    Mar 2014
    Location
    Sweden
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [problem] weird loop behaviours

    I've posted about my problems in another thread but I figured I should make a new one.
    I have a shooter game where I want damage counters to show the total damage taken by enemies. These counters pop up over their heads and disappear after 1 second after the last hit. When the enemy is killed the counter is destroyed and replaced by another counter that show the "final damage" (blue ones). The problem I have is that SOMETIMES "ghost counters" appear under the first counters, as if the pairing of ID to fixed value is lost and prevents the counter from following the hit enemy. However, the counter isn't stuck, there just seems to be another counter created under it and left in place since it shows up in the debugger.
    This video shows the ghost counter in action: https://streamable.com/f9snaz

    ghostCounters.png
    This image shows the ghost counters, enemies have been killed.

    ghostCounters2.png
    The damageRoll flag means that the enemy has been hit and has a counter. DamageRoll for the "cha" object is unrelated. The counter is created on first hit and added to while hit again (addToCounter loop).

    ghostCounters3.png
    The blue counter is created when the counters' respective enemy has HP 0. Old counter is destroyed. (The counter add furthest down is unrelated).

    ghostCounters4.png
    The counter should follow it's enemy and is destroyed when counterCool or Hp is 0.

    I recently tried to delete the ghost counters by having a for each loop check if there was a enemy->counter connection but that completely messed up the hit detection on line 235.
    ghostCounters5.png

    Any help greatly appreciated!

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    1,006
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    It's very difficult to solve a Fusion problem from screenshots - the one obvious error I could see was in line 246

    Fixed Value (Red Squiggle) <> Group.Enemies

    Since you're not scoping to any particular Group.Enemies - that part will not work as intended.

    ------------

    Line 239 you're destroying the object before trying to read its values - that might not work - and might be why you're getting phantom objects - it can't change the actual object, it was destroyed - so it finds another one to change.

    -------------

    Then I'm confused by this:
    You're always running loops and then checking for a collision inside a loop.
    It would make more sense to me to first check for a collision - and then run a loop to deal with the collision.

    ------------

    Also check your order of your loops - they're going to be run in the order of the Always event - now your loops below that don't follow that order - and if you need the information to happen in the order you've written the loops - then you need to change the order of the loops in your always event.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Vilhjalmr's Avatar
    Join Date
    Mar 2014
    Location
    Sweden
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Janette5 View Post
    It's very difficult to solve a Fusion problem from screenshots - the one obvious error I could see was in line 246

    Fixed Value (Red Squiggle) <> Group.Enemies

    Since you're not scoping to any particular Group.Enemies - that part will not work as intended.
    Yeah, I removed that line because it destroyed all my counters. I was trying to remove any counter that did not have a live object and since counters don't have alterable values the relation had to be in the enemy object. I'd of course rather not have the ghost counters appear than to patch this over. I only have this video to demonstrate it so far. https://streamable.com/f9snaz

    Quote Originally Posted by Janette5 View Post

    Line 239 you're destroying the object before trying to read its values - that might not work - and might be why you're getting phantom objects - it can't change the actual object, it was destroyed - so it finds another one to change.
    I added a timed event to destroy any enemy with hp<0 after that event instead and it works the same way, but I still have the ghost counters.

    Quote Originally Posted by Janette5 View Post

    Then I'm confused by this:
    You're always running loops and then checking for a collision inside a loop.
    It would make more sense to me to first check for a collision - and then run a loop to deal with the collision.
    I removed the "hitDetection" for the normal bullets, but I had to keep an "always" loop for my special attacks, probably because there is "spash damage" involved and many enemies are affected simultaneously. It behaved erratic when I ran the loop only on "hit" for some reason.

    I will clean up and comment my project and post it here later.

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    1,006
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Vilhjalmr View Post

    I added a timed event to destroy any enemy with hp<0 after that event instead and it works the same way, but I still have the ghost counters.
    I just meant your order of events was wrong - you just need to move the destroy event to the bottom of the list it is in - it was near the top.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Vilhjalmr's Avatar
    Join Date
    Mar 2014
    Location
    Sweden
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure where the appropriate place to keep the destroy event would be but I moved it further down.

    I commented a bit on the lines dealing with the damage counters (group "enemies - hits") and wrote some instructions.

    Try it out

    prototype.mfa

  6. #6
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    1,006
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    The order of events in Fusion is very important because Fusion goes through them from the top to the bottom.

    For example:

    * On each one of damageCounter, loop name "addToCounter"
    + damageCounter of Group.Enemies = Fixed( "damageCounter" )
    + Collision between Group.Enemies and Group.Bullets
    Group.Bullets : Destroy //step 1 destroy the old bullet
    New Objects : Create bulletHit at (0,0) from Group.Bullets //step 2 create the new bullet
    Group.Enemies : Sub attackForce( "Group.Bullets" ) from hp //set the hp based on the new bullet
    damageCounter : Add attackForce( "Group.Bullets" ) to Counter// set the damage based on the new bullet
    cha : Add 1 to damageRoll
    bulletHit : Move to layer 4


    Will give you a different result then if you ordered it this way:

    * On each one of damageCounter, loop name "addToCounter"
    + damageCounter of Group.Enemies = Fixed( "damageCounter" )
    + Collision between Group.Enemies and Group.Bullets
    Group.Enemies : Sub attackForce( "Group.Bullets" ) from hp //set the hp based on the old bullet
    damageCounter : Add attackForce( "Group.Bullets" ) to Counter// set the damage based on the old bullet
    Group.Bullets : Destroy //destroy the old bullet
    New Objects : Create bulletHit at (0,0) from Group.Bullets //create the new bullet
    cha : Add 1 to damageRoll
    bulletHit : Move to layer 4

    I've done nothing but re-order your events in your example and I can see that it creates a blue number when the enemy dies and then it gradually fades out. I think this is what you wanted?
    Attached files Attached files

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Vilhjalmr's Avatar
    Join Date
    Mar 2014
    Location
    Sweden
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My issue is with the counters showing up where they are not supposed to ("ghost counters"). I have no idea of how to fix it and keep the over all mechanics.

    A counter is created the first time a bullet collides with an enemy, the damageRoll flag indicates that an enemy has a counter. Consecutive hits then add to the existing counter and the enemy's counterCool value. A counter will exist as long as the counterCool value of the enemy is above 0 or until the hp is 0.


    The ghost counters seem to show up only when damageRoll for an enemy is on which causes me to believe it might be a loop-scope related issue perhaps having to do with:
    - Bullets hit two or more different enemies at the same time
    - The counterCool value (to destroy the counters after 1 sec of not being hit) of each enemy is losing scope and affecting the wrong enemy

    I have reordered the only event that creates counters for normal bullets to read like this, which I think makes more sense:
    ghostCounters6.png

    The ghost counters still show up but it took a lot more time.

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Vilhjalmr's Avatar
    Join Date
    Mar 2014
    Location
    Sweden
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ..and as the video shows the ghost counters show up while damageRoll is on. They must somehow have been created without the Fixed->damageCounter pairing taking place since they don't follow any enemy.

  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    1,006
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    There's still a few events where you're destroying the bullets too soon - they need to be moved to end of the list

    * Collision between Group.Bullets and Group.Enemies
    + Group.Enemies: damageRoll is off
    New Objects : Create damageCounter at (16,-23) from Group.Enemies
    Group.Enemies : Set counterCool to 60
    Group.Enemies : Set damageCounter to Fixed( "damageCounter" )
    damageCounter : Add attackForce( "Group.Bullets" ) to Counter
    Group.Enemies : Sub attackForce( "Group.Bullets" ) from hp
    damageCounter : Move to layer 4
    cha : Add 5 to damageRoll
    New Objects : Create bulletHit at (0,0) from Group.Bullets
    bulletHit : Move to layer 4
    damageCounter : Set font size to 14, border 1
    Start loop for each one of damageCounter, loop name "addToCounter"
    Group.Bullets : Destroy


    * On each one of damageCounter, loop name "addToCounter"
    + damageCounter of Group.Enemies = Fixed( "damageCounter" )
    + Collision between Group.Enemies and Group.Bullets
    New Objects : Create bulletHit at (0,0) from Group.Bullets
    Group.Enemies : Sub attackForce( "Group.Bullets" ) from hp
    damageCounter : Add attackForce( "Group.Bullets" ) to Counter
    cha : Add 1 to damageRoll
    bulletHit : Move to layer 4
    Group.Bullets : Destroy


    I've not seen blue counters left behind, but I've seen a number of other counters left behind and I think what's happening is because you're always running loops Fusion isn't picking up that a counter has already been created, because it's still in the loop, and then creating another one - which leaves a duplicate that then stays on the screen.

    But sometimes I can play the game for 3 minutes and not see a single left behind counter - other times there's many very quickly - it might also depend on how many other loops are running at the same time in the other events.

    If you have 2.5+ DLC - you can add a countdown value to the counters and just destroy them after a few seconds - that would mean they're not left behind on screen.

    Alternatively, you could just write it simpler without all the loops.

    Or if you're lucky someone else can figure this out for you :-)

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export Module
    Vilhjalmr's Avatar
    Join Date
    Mar 2014
    Location
    Sweden
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have removed all the constant loops and instead set them to run only on collisions and if number of counters > 0 etc and I think it works a lot better. I also reordered the bullets to be destroyed last in the events.
    I can go a lot longer without having counters appear where they shouldn't but now it seems that bullets randomly pass through enemies. I move them 1px per fastloop x bulletspeed and uncheked fine detection to avoid that but still..

Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Weird FPS problem.
    By blub in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 2nd July 2012, 11:02 PM
  2. Weird problem with my project!
    By NeoMonkey in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 17th February 2010, 08:03 PM
  3. Weird problem! Please Help!
    By csj1 in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 21st July 2008, 02:28 AM
  4. Weird loop problem
    By Nick in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 19th May 2008, 11:35 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
  •