How do I destroy an object by the object that it was spawn .

Get help using Construct 2

Post » Mon May 18, 2015 9:43 pm

In short enemy one shoot a bullet and enemy two shoot a bullet (the two of them are using the same bullet) so if I destroy enemy one I want any inst of the bullet to be destroy that was spawn by enemy one leaving enemy two bullet an screen.
B
27
S
5
G
1
Posts: 15
Reputation: 1,849

Post » Mon May 18, 2015 9:48 pm

Use an instance variable (ID) to identify the bullet (use enemy's UID). Then on enemy X dying, "Pick by comparison" where bullet.ID = enemyUID and destroy bullet.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Mon May 18, 2015 11:13 pm

will it work if it is more that one bullet the enemy spawn?
B
27
S
5
G
1
Posts: 15
Reputation: 1,849

Post » Mon May 18, 2015 11:18 pm

Yes.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Tue May 19, 2015 8:07 pm

I try it an it work but not the way I wanted it to.
It only set the value of the first enemy that shot.
B
27
S
5
G
1
Posts: 15
Reputation: 1,849

Post » Tue May 19, 2015 9:09 pm

You'd have to post what you've done, for any specific help.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Tue May 19, 2015 10:04 pm

On bullet created set bullet number to enemy.uid
Also it 10 enemy at a time an the stage.
B
27
S
5
G
1
Posts: 15
Reputation: 1,849

Post » Tue May 19, 2015 10:19 pm

"On bullet created" is too late. When you create the bullet in the context of the current enemy, set it there.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Tue May 19, 2015 11:00 pm

ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Tue May 19, 2015 11:04 pm

oh wait now i understood your question,



nevermind i did a capx. but no famillys just made an extra enemybullet sprite maybe helps Download Capx
B
75
S
22
G
68
Posts: 1,337
Reputation: 43,271


Return to How do I....?

Who is online

Users browsing this forum: Fradno, StarrodKirby2, ultrafop and 9 guests