Unique IDs

Get help using Construct 2

Post » Fri Jan 11, 2013 12:19 am

In the game i am doing there are different enemyes that are randomly generated, each one has its own shield attached to it like a different sprite.

I have tryed doing this with every tick - set position of shield to enemy

but when more than one enemy appears and you destroy the shield of another one, the shields start jumping from one to another

i supose that the way to solve this is with unique ID, but i don't know how

can anybody help me?
B
4
Posts: 6
Reputation: 362

Post » Fri Jan 11, 2013 12:29 am

Sounds like you need to use a container, although I'm not sure about when you destroy the shield.. I'm sure the enemy would be destroyed to. You could just set shield to invisible if that's the case. Haven't used containers in C2, only in CC and that's how they worked there.

Failing that, just set an instance variable on the shield to be that of the enemy UID. Then pick the enemy with the UID stored in the shield's variable and pin it using the pin behaviour.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Jan 11, 2013 1:02 am

Still there is something wrong, i think i havent made de events correctly
http://postimage.org/image/rfryuehg1/
B
4
Posts: 6
Reputation: 362

Post » Fri Jan 11, 2013 1:06 am

That's because you're setting the ID variable to the ID variable ;p You need to do...

Enemy3_Escudo Set ID to Enemy4.UID (you have Enemy4.ID)
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Fri Jan 11, 2013 1:15 am

You are right that was wrong, but it is still not working... i am not sure of the second event, can an event pick two instances at the same time?
B
4
Posts: 6
Reputation: 362

Post » Fri Jan 11, 2013 1:47 am

it works now, thank you very much

in the second event i put pin shield to shield, i changed to pin shield to enemy
still it didnt work so i merged the two events into one and now it works
B
4
Posts: 6
Reputation: 362

Post » Fri Jan 11, 2013 1:51 am

Ah I didn't spot that. Was too busy spotting your other error ;)

Glad you got it working!
B
15
S
5
G
7
Posts: 877
Reputation: 5,650


Return to How do I....?

Who is online

Users browsing this forum: Axiomaltd, Baidu [Spider] and 22 guests