User Tag List

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

Thread: How can I destroy child object when parent object is destroyed?

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Adnihil's Avatar
    Join Date
    Oct 2016
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I destroy child object when parent object is destroyed?

    Hey, for my game I'm using 2 active objects for each enemy. A parent object for the enemy and its values, and a child object for its animation.

    Now the issue I have with this is that I can't figure out how to destroy the child object when the parent object's health reaches 0. I mean, I can do 'Health of Parent = 0 -> Destroy Parent, Destroy Child', but then that destroys all versions of the child object (including the ones whose parent object still lives). I know that I need to add a condition that only applies to the specific enemy but I don't know how I could do this. Does anyone have an idea?

  2. #2
    Clicker Fusion 2.5
    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)
    Rebel's Avatar
    Join Date
    Apr 2014
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use fixed value for this , there was great example here on forum in sample sections. couldnt find it now, but there is try to list a bit, you will get one.

    http://community.clickteam.com/forums/352-Guides-Tutorials-Examples-Widgets

  3. #3
    Clicker Multimedia Fusion 2Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    esp's Avatar
    Join Date
    Aug 2015
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Give a look to this tutorial https://www.youtube.com/watch?v=Zz4YbXj2ooc , obviously you should use id's / fixed falues to make it happend !

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Adnihil's Avatar
    Join Date
    Oct 2016
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure how fixed value is supposed to help here. If I understand correctly, a fixed value is a unique value that every object has. How does that allow me to destroy a specific object when an other specific object is destroyed?

    I also tried using spread value but that did not seem to work. Maybe I did it wrong. What I did was:

    Always
    - Parent: Spread value 1 in Alterable Value D
    - Child: Spread value 1 in Alterable Value A

    Alterable Value E of Child = Alterable Value D
    Health of Parent = 0
    - Destroy Child
    - Destroy Parent

    However, this seems to only destroy the parent objects.

  5. #5
    Clicker Multimedia Fusion 2Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    esp's Avatar
    Join Date
    Aug 2015
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just give a look to this
    Quote Originally Posted by PixelatedPict View Post
    Hey KliK-iT, Nice example!

    I hope you don't mind, I changed it ever so slightly so that there is only one counter, and uses a fastloop to create new counters. It is attached.

    Attachment 12304
    from this old post http://community.clickteam.com/threads/85487-Independent-Health-Bars

  6. #6
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Adnihil's Avatar
    Join Date
    Oct 2016
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I appreciate you trying to help me but that example simply doesn't have anything to do with what I need help with. I've got alterable values and healthbars working fine already. Maybe I wasn't clear, let me try to explain again.

    In my game, an enemy gets created every time the player takes X amount of steps.
    An enemy consists of 3 objects;
    1. Active object - Position, Alterable values, behavior etc (Parent object)
    2. Counter - Healthbar (Child object that follows the Parent object)
    3. Active object - Appearance and animation (Child object that follows the Parent object)
    When the Health (alterable value) of an enemy reaches 0, it is destroyed.
    When the value of a healthbar reaches 0, it is destroyed.

    However, how can I make it so the other active object (child object) is destroyed when its parent object is destroyed?

  7. #7
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,301
    Mentioned
    27 Post(s)
    Tagged
    0 Thread(s)
    On creation you would stored the fixed value of the parent in an alterable value of the children. When the parent health value reaches 0, simply run a for each loop on each child object type and compare the fixed value of the parent to the fixed value stored in the child's alterable value and destroy it.

  8. #8
    Clicker Fusion 2.5
    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)
    Rebel's Avatar
    Join Date
    Apr 2014
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    searched over 20 pages in tutorials and widget couldnt find it, so here the sample for fixed values.
    Attached files Attached files

  9. #9
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Adnihil's Avatar
    Join Date
    Oct 2016
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you all very much for the help. However, I've been trying for 2 days now and still haven't gotten it to work correctly.

    I made this (extremely) stripped down version of my game. Could someone please look at the mfa and tell me what I'm doing wrong here?
    Attached files Attached files

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleSWF Export Module
    Nippe's Avatar
    Join Date
    Oct 2011
    Location
    Sweden
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    While Fusion do link objects together automatically, it's not really an exact science. So it's always a good idea to give them an ID so that you can refer to each individual object.

    Some things to keep in mind:

    Give child objects a reference Alterable Value to the parent.
    Remember to destroy the child object before destroying the parent.
    Use loops to deal with multiple overlapping objects.

    Take a look at the attached mfa.
    Attached files Attached files

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Replies: 3
    Last Post: 8th December 2016, 10:19 AM
  2. Understanding ForEach Object and Parent/Child Objects...
    By TheFieryPlumber in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 24th May 2013, 03:19 PM
  3. ID / Parent Child connection, object linking, ones and for all
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 28th October 2012, 09:21 PM
  4. Is there a parent child heirarchy object?
    By turtle in forum Multimedia Fusion 2 - Technical Support
    Replies: 18
    Last Post: 12th July 2010, 04:40 AM
  5. Parent-Child?
    By xhunterko in forum File Archive
    Replies: 2
    Last Post: 6th December 2009, 08:18 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
  •