How do I update a variable where there are multiple instances.

0 favourites
  • 7 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • So. I have player base(s)

    I have bodies.

    Each base spawns and pins a body. And gives it the same variable to group them. count.

    I want the base to tell the body its angle every tick. In a variable .deg.

    I've tried

    for each torso, base.count=torso.count

    Set torso.deg to base.deg.

    But this only seems to affect one instant of the torso, or it affects them all.

    Is there a better function to do this? Like for each instance.

    Or, a better way to check sprites individually?

    Or should I group them into families?

    I can post a demo if needed

  • for each torso, base.count=torso.count

    What condition are you using? You need conditions which pick instances. For example "Base -> Compare Instance Variable".

    If you are using System conditions like "Compare two values" - they don't pick instances.

    Also, linking with Pin and instance variables is an old method. In C3 you can use hierarchy - it will be much easier. Add Body as a child to the Base sprite. You can select which properties will be synced automatically, for example the angle. And you can use "Base Pick Children" condition to pick the Body sprite.

    EDIT: Container is another option. Or use both the container+hierarchy for maximum automation.

  • Put Base and Torso in a 'Container' (see manual for more info). This means when you create a Base, it will also spawn a Torso, and they will relate to each other in events automatically without having to use variables.

    Also I'm not sure how you created a custom variable called Count, that shouldn't be possible afaik.

  • Wow! Yup, I'm a construct 2 guy. Just working from what I remember.

    I'll try hierarchy or containers. Construct 2 had families. I toyed with the idea, but couldnt find it..

    So just tried brute forcing it.

    Lionz, no it's a variable called bodycount. Was just trying to simplify it for the example.

    Thanks for advice guys. Apprieciated

  • Ah. Yeah. So. I have bodies linking to bases.

    But, I have several sets of bases. All spawning in their own torso.

    Will I need to make several bodies to corilate to their own group?

    Guess I'll find out soon enough

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • But, I have several sets of bases. All spawning in their own torso. Will I need to make several bodies to corilate to their own group?

    For containers - yes.

    For hierarchies - not necessary, you can combine any objects.

  • Wow. Hierarchy is powerful. Had no idea. So simple! Thanks for the shout this will make everything easy

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