How do I link 2 objects?

Get help using Construct 2

Post » Mon Jul 28, 2014 8:29 pm

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 :D
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)
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Mon Jul 28, 2014 9:15 pm

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?
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Mon Jul 28, 2014 9:43 pm

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
B
71
S
30
G
25
Posts: 984
Reputation: 19,503


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 37 guests