Please help with BALL AND CHAIN capx. :(

0 favourites
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hey guys. I've been trying trying to create a proper chain link from scratch since I'm having a hard time getting the PIN function to work the way I want to.

    So what I did was put the origin of a single link close to the front and used that for positioning as well as angles.

    Right now I have a hard time figuring out how to CONNECT THE TWO CHAINLINKS.

    I also want to know how to CREATE MORE CHAINLINKS when both the balls are far enough from each other but I don't know where to begin.

    I hope you guys understand my problem. Thank you.

    CAPX: http://s000.tinyupload.com/?file_id=050 ... 9750723852

  • 24 hours, Yo!

    Bump! >; )

    EDIT: 24 h + 5 Minutes too late... : (((

  • This is something I still haven't figured out after a year.

    R0J0hound do you mind taking a look at my Capx?

    I have a problem getting the links of the chain to link at the opposite end.

    I've tried revolute joints but this isn't really a capx that needs physics.

    Capx: https://www.dropbox.com/s/4zaon4bgge5s1 ... .capx?dl=0

  • Hey MPPlantOfficial

    At first I though "how hard can it be? Just pin links to each other!"

    Turned out - quite hard <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Here is what I came up with:

    https://www.dropbox.com/s/4ach2ss7ujtbx ... .capx?dl=0

    The code is quite dirty and can be optimized, but I hope you find it helpful.

    Sorry, I didn't modify your capx, it's too complex.

  • Here is what I came up with:

    https://www.dropbox.com/s/4ach2ss7ujtbx ... .capx?dl=0

    The code is quite dirty and can be optimized, but I hope you find it helpful.

    Gold! Sorry didn't reply earlier. I haven't gotten the chance to check back immediately.

    Thanks again! <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

  • Sorry, I didn't modify your capx, it's too complex.

    Oh I forgot to specify.

    I actually wanted one end to be grounded while the other one moves. That was the challenging part.

    I imagine it'll take something like 2 loops constantly following the moving chain while the "grounded" end "tugs back" at the same rate when max distance is exceeded.

    Speaking of which, I could start there:

    RedBox/Greenbox is dragging

    Distance Bar greater than or equal to [cumulative lengths of all chain links] | [some code to keep opposite box grounded.]

    This was my initial struggle

  • Basically think of Chain Chomps from Mario / Zelda WITHOUT the gravity.

    As you can see, each link follows the head but stays grounded on the opposite end.

    If this is a nightmare to program now, how much more back then? XD

  • Here's my approach. It's more like a rope than a chain. I wasn't able to get that nice loose link feel of dop2000's.

    https://www.dropbox.com/s/95ht71np5jrti ... .capx?dl=1

    Fixed end version. Basically pulls one way, minus the last, then pulls the other way.

    https://www.dropbox.com/s/ecjsc9mmn509i ... .capx?dl=1

  • R0J0hound

    Wow, this is so cool and works so much better than my petty attempt!

  • Thanks dop2000

    I rather like how yours bunches up like a real chain, and letting two chains connect is a nice touch. I'll have to look at how you did that for ideas.

  • Fixed end version. Basically pulls one way, minus the last, then pulls the other way.

    https://www.dropbox.com/s/ecjsc9mmn509i ... .capx?dl=1

    Excellent capxs guys.

    I don't know what's happening here:

    chain.index*(loopindex("i")?-dir:dir)

    particularly the ("i")?-dir:dir part but I'm gonna study this example.

    It's impressive how you managed to do it without a second image point for the links as well.

  • A ? B : C is called ternary operator.

    It basically means "if A is true, then B, else C"

    So this formula reads:

    chain.index* (IF loopindex("i")=1 THEN -dir ELSE dir)

  • Also to explain why I used that:

    Chain.index is the order of the objects in the chain. 0 on one end up to say 10 on the other.

    Used with "for each ordered" it will loop over the objects from one end to the other.

    We can also make it loop backwards by multiplying chain.index by -1.

    I used the "dir" variable to specify what direction to use. In the first capx the direction is chosen so the end being dragged is first.

    For the fixed end version it loops twice. Once one direction, then once the other. You could just as well duplicate the loop event and use this instead if that helps.

    For each chain ordered chain.index*dir

    --- do stuff

    For each chain ordered chain.index*-dir

    --- do stuff

    I used equations to cram it all together. It probably would be more readable utilizing functions. Maybe.

  • A ? B : C is called ternary operator.

    It basically means "if A is true, then B, else C"

    I see. Thanks for explaining.

    For each chain ordered chain.index*dir

    --- do stuff

    For each chain ordered chain.index*-dir

    --- do stuff

    I used equations to cram it all together. It probably would be more readable utilizing functions. Maybe.

    Nice! I'm learning new stuff everyday!

    I was actually going for that approach as well however I did not know how I would be positioning the chainlinks for the second loop using their second image points as reference points.

    Thanks again, guys!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A

    Also to explain why I used that:

    Chain.index is the order of the objects in the chain. 0 on one end up to say 10 on the other.

    Used with "for each ordered" it will loop over the objects from one end to the other.

    Hi guys I'm sorry to be revisiting this yet again but would you happen to know a way to create new chain links?

    The loop seems to be [for each chain order] using the family.

    I'm going to assume The order would be something like: Dot A Link 1,2,3...Link2-Dot B

    Newly spawned links seem to stick to the current active Dot and produce a weird effect. How do I spawn a link such that it sequences itself in between all link and link2?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)