All objects are being destroyed instead of one?

Get help using Construct 2

Post » Mon Mar 28, 2016 9:12 pm

Hello there,

I've been checking out some capx samples and did some reading on tutorials and forums but have not been able to fully understand it yet and adapt it to my specific case.

So hence I'm asking it here on the forum.

When the aircraft shoots bullets and hits the T72 5 times the T72 is destroyed. But currently it destroys ALL the tanks that are spawned every x seconds. I have a global variable 'T72health'.

This is the bit I have and think needs change?

Image

I know I have to pick instances but I just don't understand how to implement it.

Thanks for any help.

Regards R

I can post more bits if necessary.
B
13
S
7
G
4
Posts: 136
Reputation: 3,567

Post » Mon Mar 28, 2016 9:25 pm

You should be using an instance variable for the tank health instead of a global variable. So to do this select the tank sprite and on the left in the properties click the blue text instance variables create one called health and start it off at 100. Then when a bullet hits it subtract 20 from that variable once the variable hits 0 spawn an explosion and destroy the tank. .CAPX attached.

https://dl.dropboxusercontent.com/u/729 ... ample.capx
Image
B
45
S
17
G
2
Posts: 201
Reputation: 4,471

Post » Tue Mar 29, 2016 5:19 am

You can try pick by evaluation hp < or equal to 0 and yes use instance variable hp on the tank sprite.

And then do destroy tank. The picking event picks the ones that has met and will continue to do so until the action is done.

Take a step back from your work and write down the logic in a form of a question and then ask someone on that specific task. Construct two and other engine are very dumb they do no have our dynamic brain capability and require specific instruction. In other word just know that you are smarter then the engine you have to dumb down the code for the engine to know what you want.
B
51
S
24
G
6
Posts: 391
Reputation: 7,820

Post » Tue Mar 29, 2016 11:02 am

Thanks so much guys, it works perfectly now. And the solution was so easy.

Regards
B
13
S
7
G
4
Posts: 136
Reputation: 3,567


Return to How do I....?

Who is online

Users browsing this forum: Sparkz and 2 guests