How do I break the chain?

Not favoritedFavorited Favorited 0 favourites
From the Asset Store
A heart-pounding album featuring 8 electrifying tracks designed to fuel epic battles and high-stakes confrontations.
  • I'm not sure I can answer your question. Your game is pretty complex, and while switching to hierarchies has probably made things a bit cleaner and more organized, it's still a complex system.

    All I can do is share how I would probably approach this task:

    1. Pick all moleks that are still in the hierarchy (i.e. children of Chemic). First, set attached = false for all of them.
    2. For each molek in the hierarchy that is directly overlapping (touching) Chemic: set attached = true.
    3. For each molek in the hierarchy with attached=false: check if it’s overlapping another molek with attached=true. If so, change its attached to true. (You might need to use a family: “Molek is overlapping MolekFamily.”)
    4. Repeat previous step until none such moleks left.
    5. Any remaining moleks in the hierarchy that still have attached=false at this point have broken off from the chain. Remove them from the hierarchy and launch them away.

    This helps. How would Step 3 look like?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You'll need to add Molek sprite to a family, and move instance variables from the sprite to the family level.

    Then you will be able to pick both in the same event, something like this:

    Chemic pick children Molek
    Chemic pick children MolekFamily
    
     Molek is attached
     MolekFamily is NOT attached
     Molek overlapping MolekFamily 
     ----> MolekFamily set attached to true
    
Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)