Speedy1SonicBoy's Forum Posts

  • That's only a small part of the code. Did you implement all other steps? It feels like you don't fully understand the idea.

    Here is a demo - click any molek sprite to destroy it and break apart the remaining chain.

    Very cool. I see what you mean now. But now it leads to another question: with everything implemented before (That is here: construct.net/en/forum/construct-3/how-do-i-8/attach-sprite-specific-way-183986), with everything formerly worked on there, how would I now implement the new into the old?

  • Just so I can figure out if I got the aforementioned code right:

    But I must be doing something wrong, because very little has changed.

  • That's why we use families:

    > Molek is attached
    MolekFamily is NOT attached
    Molek overlapping MolekFamily
    

    I figured as much. Would I use MolekFamily instead of Molek for all the preceding code as well?

  • What do you mean? Where what would go?

    I meant to say, where would the script go in terms of lines? Also, would I have to replace every instance of molek with the family in the script?

  • 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
    

    This confuses me a little. Where would it go?

  • 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?

  • So the easiest fix is this:

    > + Molek: On destroyed -> Wait 0 seconds
    ----+ System: Pick all Molek
    ----+ System: For each Molek
    
    

    That works... too well. Lol Now I'm having instances of molek fly off that are part of other chains.

    How would I be able to isolate only the affected chain, what in the conditions below would I have to amend/add?

  • I just realized I had a line similar to this, and added the add key line in the end. I'm assuming it needed a value of 1 so that's what I put down.

    What's next?

    This is what I put down underneath the main clause that breaks the chain visually, but so far it does nothing. Is there anything here I'm missing? Or might I be missing something somewhere else?

  • Here is an example:

    > Chemic pick children Molek
    For each Molek
    ... Dictionary add key Molek.dx & "," & Molek.dy
    

    I just realized I had a line similar to this, and added the add key line in the end. I'm assuming it needed a value of 1 so that's what I put down.

    What's next?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • One other thing to consider about the hierarchy system: it doesn't support loops. So if you need looped chains, like in the image below - you’ll have to connect all Moleks directly to Chemic.

    In that case, when any Molek is removed, you'll need to check which Moleks are still connected to Chemic and rebuild the hierarchy accordingly.

    Good to know! Looks like I'll have to do that to support loops. Still, building a dictionary from hierarchy... how would I go about doing this?

  • There are two ways to build the hierarchy: either attach all Moleks directly to the parent Chemic, or create a chain. I’m guessing the chain would be more suitable in your game. If a middle (blue) Molek in the chain is removed, it will automatically break into two smaller chains. Or you can detach pink molek from yellow as well.

    I'll try for the latter case in this instance. Basically anything breaking off from the chain will act as they would if Z were pressed, and (in this example) pink and yellow would bullet out of there separately from each other.

    I’d strongly suggest using the hierarchy feature instead, it will be A LOT easier. Attach Moleks to Chemic as children - this way, they’ll automatically move together and stay logically connected. You won’t need dictionaries or extra variables at all. You can find parent or child object at any time with "Pick parent/child" condition.

    The dictionary will be necessary for another aspect of the overall project that this stems from, where I'll need to call on it for an overall shape to be built, checking if numbers match the shape intended.

    construct.net/en/forum/construct-3/how-do-i-8/check-shape-built-185425

    It seems to be the only thing that works so far, and to remove the dictionary entirely would mean to overhaul this system that's worked for me.

    With all this in mind, where would you suggest the overhaul begin?

  • There's more to the code than I can successfully screenshot, I'll be able to show you via the project file itself:

    drive.google.com/file/d/1x-GN_g_PbKfzClApM8vNFcr6RX3ITA5r/view

    Bear with me, the link should work, but I'm not entirely sure how to do it with Dropbox, so I did it through Google Drive instead.

  • The chain is made with events.

    So the initial part of the chain is the Chemic itself, then another Molek or set of moleks that will then be destroyed upon touching alpharay. (Or betaray, which I don't have in the example but I do have in the rest of the project.)

    Thing is, I tried the condition of overlapping Chemic or Molek but neither worked.

    I think the solution might have something to do with the markers themselves. Maybe if I can have the system check if 4 markers can be looped around a molek, for it to then detach.

    How would I go about making that a condition, however?

  • I have a unique problem in my hands.

    So I have a system that attaches sprites in a chain. When that chain breaks, I hope that the sprites detach accordingly. Unfortunately the below circled sprites act as if still attached!

    I've already figured out how I'd want the sprites to act. The question is this: what do I put in the conditions tab to make it so the system checks for a break in the chain?

  • Set rotateSpeed to lerp(rotateSpeed, 0, 0.05)?

    After a few tweaks, that seems to be it! Thanks!