Problem with instance variables

Get help using Construct 2

Post » Sat Jun 06, 2015 10:54 am

Hi!

I'm trying to do something like this:
- Sprite has a "life"-like instance variable
- On collision with a bullet -> substract 1 from this "life"
- When "life" is less or equal than 0 -> wait 4 seconds and reset the "life" counter
And so...

But after the first "life" reset, when a bullet collides with the sprite again, it substract 1 from life and resets to 4 again 3 or 4 times and I don't know why is this happening.

Here is a .capx: https://www.dropbox.com/s/4topqyf2q10jqqp/problema.capx?dl=0

Could somebody help me with this?
Thanks
B
12
S
2
G
1
Posts: 32
Reputation: 756

Post » Sat Jun 06, 2015 11:03 am

Would adding a condition to the on bullet collide event help?

Bullet on collision
player compare variable is bigger or equal to 1
> player subtract 1 from variable..

Also..
The wait action is called every tick if player variable is less then 0
Adding a trigger once while true would help..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Jun 06, 2015 11:25 am

Adding the "trigger once while true" condition did the trick.

Thanks!!!
B
12
S
2
G
1
Posts: 32
Reputation: 756

Post » Sat Jun 06, 2015 11:37 am

Sanju83 I have corrected your CAPX Problem.capx you will find it here in below link

https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0
B
245
S
37
G
15
Posts: 1,939
Reputation: 40,087


Return to How do I....?

Who is online

Users browsing this forum: mrkaio, Zav and 3 guests