Linking two objects through an unique ID

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • How can I link two objects and then run events to target a specific object?

    For example, lets say there are some characters with a health bar that follows them around:

    Please login to see this attachment.

    Creating this link is easy enough, and I've attached an example file to the thread.


    But now I want to run an event that targets a specific object. This could be when the health bar reaches "0" and I want both the health bar and its linked object to be destroyed.
    I know there is some trick to this, but I have forgot how to set it all up ?(

  • You can link a single health bar to an object by using:

    - an alt. value, ex. ID on the health bar, an set it to the "fixed value" of the other object.

    This way you can test something like

    if health bar ID = fixed value of ( object ) then...

    And take the desired option.

    That fixed value is an unique number that every object has. So when you create zhe health bar for an object, you can store the fixed value of thst object in the ID alt. value of the newly created heslth bar.

    I hope it makes sense for you.

    Regsrds,

    Sergio

  • That seems to only work when they are created through an "on each" loop.

    Here I create the green square and set the ID to match the fixed ID of the red circle, which in turn has its ID set from the fixed ID of the blue triangle. All the shapes now share the same unique ID, but the green square does not follow its pair

    Please login to see this attachment.

    Please login to see this attachment.

  • This is because the right hand side of conditions doesn't select multiple expressions. So it takes the first selected object (first red) on right hand side when comparing in event 8, and selects all greens that match it, which would just be one.

    The reason is that when it gets to action part, that implicit pairing isn't done again each time an action is run; it doesn't check every red matches the green in event 8 actions.

    Actions are done in a loop, with the action done one by one in an action, so that's probably why event 5 works; it picks the nth selected for green and nth selected for red in the loop. For consistency, though, you shouldn't rely on that, because I'm not sure what happens with nth if you have 5 matching reds and 3 selected greens.

    Darkwire Software Lead Programmer (C++ & C#)
    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

  • This is because the right hand side of conditions doesn't select multiple expressions. So it takes the first selected object (first red) on right hand side when comparing in event 8, and selects all greens that match it, which would just be one.

    The reason is that when it gets to action part, that implicit pairing isn't done again each time an action is run; it doesn't check every red matches the green in event 8 actions.

    Actions are done in a loop, with the action done one by one in an action, so that's probably why event 5 works; it picks the nth selected for green and nth selected for red in the loop. For consistency, though, you shouldn't rely on that, because I'm not sure what happens with nth if you have 5 matching reds and 3 selected greens.

    Thanks for the explanation!
    But then how should I "pair" objects with the same ID?

  • Yep, that's the usual way.

    In similar designs, you have to think ahead: if Red triggers an event and needs to select one green, can it select it by having it on left hand side, or will Red not have green's ID? Should Red get its ID set in creation event instead for efficiency? Is NCount("object") fine for unique ID, or will some object be deleted later and it will make later created ones have non-unique IDs?

    Some folk just use fixed values if they're pairing, since they're unique anyway.

    Darkwire Software Lead Programmer (C++ & C#)
    Please login to see this link. | Please login to see this link. | Please login to see this link. | Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!