# [SOLVED]Problem with health mechanic.

Get help using Construct 2

### » Wed Feb 18, 2015 5:57 am

Hey guys!
Hope you all are doin' better than me.

I have this nasty problem with a math (?) formula (don't know if I spell that right), or at least I think it's because of that since I suck at logic and maths :3
Here:

The thing that happens, is that everytime the player gets a shoot the ActualHealth goes from 100 to 0, instead of taking the 10 from the impact ( the variable Difficulty is at 1, and PlayerShip.Plating is at 0 ). Then if you take a second shoot, it doesn't go negative but increases to +10; and it stays as 10 then, no matter how many shoots it recieves.

Any ideas guys? I'm really troubled by this, since the formula I want to use when the shield gets activated, its based on this one too. º^º

Ps: Please excuse my english and grammar.
Cheers~
Last edited by Frame Matt on Thu Feb 19, 2015 3:38 pm, edited 1 time in total.
B
9
S
1
Posts: 20
Reputation: 709

### » Wed Feb 18, 2015 6:10 am

@Frame Matt
Can you give us capx or wider picture of the whole sheet?
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

### » Wed Feb 18, 2015 6:12 am

DamageTaken should be called before PlayerHitted()?

Also make sure your variables are numbers and not strings.
B
32
S
7
G
2
Posts: 317
Reputation: 2,871

### » Wed Feb 18, 2015 3:02 pm

I would preffer to not submit a capx, but hopefully this images do the job.

Here's the whole pic of the sheet on where I think it's the problem

The other 3 player groups have no event related to this matter.
---

Here the function GUIUpdate, which is called by PlayerHitted.
---

Both event sheets are loaded on the main sheet.
---
And here are the variables.

---
IndieKiwi wrote:DamageTaken should be called before PlayerHitted()?
Also make sure your variables are numbers and not strings.

When did that, the first hit, instead of drop the health all the way to 0, it drops to 10. :/

*I don't know if we're going to solve this, but still, thank you for your help guys (:
B
9
S
1
Posts: 20
Reputation: 709

### » Thu Feb 19, 2015 5:20 am

You should try the very basic. "Hp - damage". Then display it. and add to it one step at a time.
B
32
S
7
G
2
Posts: 317
Reputation: 2,871

### » Thu Feb 19, 2015 3:37 pm

I actually did that! but couldn't find anything.

But a user on a Construct 2 LatAm facebook group, told me to change the "substract to" on the function PlayerHitted, for a "set to". And it seems to be working, I've been moving some parameters to check how the formula does, and it looks fine. When you think about it, it makes sense to have it setted for "set value to".

So, I guess, that's the way to go when you are doing maths that change the overall value.

Still, thank you guys <3
B
9
S
1
Posts: 20
Reputation: 709

### » Sat Feb 21, 2015 10:42 am

@Frame Matt , you should reference people in future, so they get your alerts so they can answer you
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

### » Sat Feb 21, 2015 7:46 pm

Oh, that's the tagging for?
I, actually, was subscribed to this topic via e-mail. I'm certainly going to try it next.
Thank you @razorMonkey (:
B
9
S
1
Posts: 20
Reputation: 709

### Who is online

Users browsing this forum: urkokan and 11 guests