uid link dummy sprites leaving their child behind

For questions about using Classic.

Post » Sat Sep 22, 2012 3:27 pm

I have a feature i am working on in my game where the enemy is destroyed, and a coin shoots out and homes in on the player for auto collection.

the problem is, I am using a dummy sprite on a bullet behaviour to rotate to the player object at a rapid speed of 400.

each enemy, before it is set to destroy, creates a dummy sprite with the bullet behaviour, then immediately after a coin sprite is spawned that takes the UID of that dummy and stores it as a private variable. and the matching coin variable is used to pair the coin with the dummy..

which I believe is the correct way of doing things..right?

problem is, a singular destroyed enemy is fine and works as it should, but if i destroy enemies in rapid succession, the parent dummies are moving as they should to the player, but are leaving some (not all) of the paired coin sprites behind...

I'm using:

(event)

Always
coin value = to dummy UID

(action)
coin sprite set x to dummy .x
coin sprite set y to dummy .y

can anyone help?work32012-09-22 16:06:21
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Sat Sep 22, 2012 8:11 pm

Replace the always with a "for each dummy".
B
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Sun Sep 23, 2012 5:44 am

Amazing! thankyou so much - should I be using this for any multiple instance of anything? for example, particle fading or scaling?

B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Sun Sep 23, 2012 1:43 pm

Ah, maybe not so amazing.. It's still doing it....this one is really vexing me
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Sun Sep 23, 2012 2:32 pm

after a bit more experimentation, it seems it is actually the spawning event is causing the trouble (?)

it seems the graphic that follows the parent dummy gets left behind when objects are overlapping, so I stacked a bunch of static enemies on top of each other and killed them in game, and all the child graphics were left sitting there, while the dummies all did what they were supposed to do..

heres a snap of the event i'm using to spawn the dummies and child overlay

https://www.dropbox.com/s/o8j8pu7roo5lvix/event.png

could it be a family issue or a UID issue?? I'm stumped..

thanks for your time!
work32012-09-23 14:33:25
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Sun Sep 23, 2012 8:30 pm

Your event will work fine when there is only one enemy with destroyed=0. If there is more than one enemy with destroyed=0 then only the last created gem and gemcollide will get modified. This is because create/spawn actions pick only the object being created.

The solution is to handle the enemies one at a time by adding a "for each enemy" condition to the bottom of that event.
B
79
S
24
G
53
Posts: 4,728
Reputation: 40,219

Post » Mon Sep 24, 2012 2:30 am

Thank you so much.. Is there a guide anywhere for each condition and what they do? I guess I need to learn a bit more about the conditions I don't know about or use..

Thanks again, you got me moving forward with my game!
B
4
S
2
G
5
Posts: 149
Reputation: 2,025


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests