Objects following each other

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.
  • I have a system where a big object is created at a point along with one or more smaller objects, the smaller objects need to follow the bigger objects around. There needs to be multiple instances of the bigger objects, each with instances of the smaller objects following them.


    For example:

    One object is created along with three instances of different, smaller objects that always follow it

    Another instance of that object is created along with three instances of different, smaller ones that always follow it

    And so on.


    I'm struggling to get this to work reliably, I can't get the smaller objects to follow the bigger objects that they're supposed to be following. If you could help me out I would appreciate that.

  • one way could be:

    by creating a big object, create also the three small object in the same event ( this to have the object scope preserved ), so that you can set an alt. value ( for example: ID ), of each small object with the unique value ( fixed value ) of the big object.

    This way you have a big object with three "children" objects connected to it via the alt. value "ID".

    Now, when you move that big object, set the desired position of each small object having the alt. value ID equal to the fixed value of the "parent" big object. Again, use the same event ( or also a child event ) to have the scope access to the right big object. A for..each loop on the big objects will do the job.

    This way each small object will follow it's parent big object.

    I hope it makes sense to you.

    Another way could be:

    if the big object and the small objects are static sprites without animations, you may create a big sprite having the big object and the three small objects inside the same sprite/image, leaving the rest of the sprite transparent.

    This way you only have to move the big sprite ( wich acts like a container ) and the big and the small objects will "move" accordingly - I hope you get my drift :)

    Third way: there is an obhect called "object mover" if my memory serves. It acts as a container. All the objects that are contained inside it will be moved when you move it.

    You could create such an object, put the big object and the three small ones just created inside the container, and move it as you like. All the four objects will move accordingly mantaining it's relative position between each other.

  • Thanks very much for the responses. Sorry if I wasn't that clear in my original post but I've made an MFA to illustrate it a bit better.

    If I use the object's fixed value it seems to work for one instance of the bigger object, but if there is more than one instance in the frame the smaller objects stop following it. Is there something I'm doing wrong?

    Any help is greatly appreciated.


    Please login to see this attachment.

  • The scope of the card is not defined when you try to move the small objects that belong to it. You have to define it by selecting a card, for example with a for..each loop.
    I've modified you example. I hope it helps.

    You can optimize the code by running the for..each loop only when a card is moving. Right now the loop runs always, but this does nothing to the performance.

    Again, if the small objects are static ( no animation ) you may consider it as a part of the image of the card. This way you have less active objects ( which is good for the performance ) and less code.

    Regards,
    Sergio

  • Hi Sergio, thanks very much for the help.

    I can't open the MFA I think because I don't have the 2.5+ DLC or the developer version. I get a 'file cannot be loaded because it has been created with a newer version' message.

    Is there any way around this? Thanks again.

  • Hi Sergio, thanks very much for the help.

    I can't open the MFA I think because I don't have the 2.5+ DLC or the developer version. I get a 'file cannot be loaded because it has been created with a newer version' message.

    Is there any way around this? Thanks again.

    I strongly suggest you to buy the DLC, since it adds lots of important features and is really worth it ( like for example child events ).
    That said, here the screenshots of the modified code:

    Please login to see this attachment.


    Please login to see this attachment.

    Hope it makes sense to you,
    Sergio

Participate now!

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