Spawning unique instances

Get help using Construct 2

Post » Sat Feb 15, 2014 6:16 am

Urgh, so I am a new user and cant post URLS yet so hopefully this is clear enough.

I am using 'Create Object' to spawn 2 objects, a Parachute & an Item attached to the Parachute with Pin.

When I click on the Parachute it gets destroyed and drops the item to the ground.

This all works perfectly.

BUT

I have it so that every 3 seconds a new Parachute/Item object set gets created.

when I have multiple of these on screen at once, and I click on one of them ALL of them drop the item & get destroyed.

Is there a correct way I should be doing this so they all act independently of each other, whilst still using the On Click action?
B
4
Posts: 18
Reputation: 230

Post » Sat Feb 15, 2014 6:28 am

You need to keep track of the UID that you are pairing the item/parachute to. Add an instance variable to the parachute, set it to the UID of the item, then on-click, do a Pick by UID for the item so the correct one is selected.
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Sat Feb 15, 2014 8:07 am

You can check if each object "Is pinned" and if it's not, drop it to the ground.

edit: you can post the URL, just leave out the colon or the slashes for us to fill in.
(you can probably get to 500 rep real fast too. See the easier rep to earn here: https://www.scirra.com/me/rep )Paradox2014-02-15 08:12:47
B
233
S
62
G
33
Posts: 902
Reputation: 40,398

Post » Sat Feb 15, 2014 8:29 am

You are not using the good condition :

It's not on click, it's on object clicked you should be using.
Something like this :
Mouse => on object clicked => parachute => parachute destroy

Only the clicked parachute will be destroy.

if you use :
Mouse => on click => parachute destroy
it will of course destroy all parachutes
B
10
S
2
Posts: 67
Reputation: 690

Post » Sun Feb 16, 2014 8:44 pm

Thanks for the replies, will check out the UID stuff sounds like the way to go!



[QUOTE=Daedolon] You are not using the good condition :

It's not on click, it's on object clicked you should be using.
Something like this :
Mouse => on object clicked => parachute => parachute destroy

Only the clicked parachute will be destroy.

if you use :
Mouse => on click => parachute destroy
it will of course destroy all parachutes[/QUOTE]

I am using on click - parachute, but it doesn't identify them as unique currently.

B
4
Posts: 18
Reputation: 230


Return to How do I....?

Who is online

Users browsing this forum: Armench and 14 guests