Hello,
In my game, the hero wears an armour and has some health points.
When they attack the enemy, first the armour should deplete and then the health.
However, in my code only armour is reducing and not the health.
Not sure how to approach this.
Before moving
After moving and colliding
The code:
The last event has a trigger once but because it’s a subevent of the collision condition, the collision is also being used for the trigger once so the trigger once gets removed after each collision. It’s basically a trigger once per collision and armor=0 than just armor=0.
You can either move the subevent to its own event. Or leave it there and change the armor variable to say - 1 as an action. That way, it won’t be zero the next time.
1 Like
Thank you @Keith_1357
Your solution worked!
I tried your first suggestion.
Here are the results:
Code:
I’m not sure how that fixed it. Imtnot con out is. It’s still checking both the collision and the armor. My idea was just to move the armor event so it wouldn’t also check the collision. That way the collision wouldn’t clear the trigger once.
It could be that the event order is now inverted. Maybe, before it might have been causing a bit of a chain reaction.
Before:
If armor = 1 set armor - 1
If armor = 0 set health=5
1 Like
To test out your hypothesis about inverting event order, I placed the events in descending order.
Code:
Results before collision
After collision:
Also I removed ‘trigger once’ to check:
And it still works!
I also can’t pinpoint how it’s working, but, hey, it’s working!
Edit: I think, once the enemy is deleted, there is no collision and it does not check for strPlayerArmour = 0
1 Like