How do I link 2 objects?

  • I have 1 sprite called AICar, this is the car with the racing logic in my game.

    Then I have a family with all the other cars possible sprites, I select one of the family members and create it so it stays over the object with the logic and replaces it with a cool drawing

    The problem is that I need to set the correct animation depending on AICar's angle of movement. How can I link each "coverSprite" to their respective AICar object, they are all create dynamically in a loop until now. Can I use UID or IID for it? I've never messed with them.

    So far all "coverSprites" change their animation in relation to the same AICar object. (not sure if 1st or last one created)

  • I solved the problem creating instance variables (id) for the family and the AICar object, the I run a for each loop on AICar, and pick family where Family.id equals AICar.id, but my doubt remains, could I have used uid or iid for it? How do they work?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A common "id" instance variable is one way to do it. But as you said, you could have created a AICarUID instance variable in your "coverSprite" object, then in a "For Each AICar", pick coverSprite object where coverSprite.AICarUID = AICar.UID

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