I’m making a top down game, and I made an enemy but when the player hits it (player health bar 100), it should subtract width by 10, it does it once but only once. I copied the code from Gdevelop’s heathbar online tutorial: GDevelop 5
It should work, I see no reason it can’t.
TRIGGER ONCE means the logic will only trigger once whilst true. So if you’re colliding with an enemy you will see the -10 health, however the logic wont fire anymore until the trigger once is ‘reset’ (by no longer colliding with the enemy).
The reason it works with the example is if you’re colliding with an enemy whilst stationary it forces you to jump which not only puts your character in a position to kill the enemy but ‘resets’ the trigger once since you’re no longer colliding with the enemy.
If you were to disable the jump in the example you would find your self in the same situation.
Thanks for your reply!
I tried removing the simulate jump code, but the player gets hit when touching enemy once then I move away and come back and touch it again the life bar drops again, and if I repeat, depletes the life bar.
For my game I want that to happen exactly.
Here is a link to my game. If you move over to the left and walk into the black alien thing it should hit player once then when you walk off and come back over to it, it doesn’t do damage again. But the hit sound effect works multiple times.
Sorry I’m really new to GDevelop and game making in general, so the fix might be obvious!
Also I’ll put the full events on here, (I used RPG starter thing for this so there is a lot of stuf from that)
playerhealth is being set to 100 on each frame. So, whenever there’s a collision the health is always set to 90 and the scale is set to 90/100 or .9 each time. So, it only changes once.
Thanks for your reply. Do you know what I should do to fix that?
Remove the action that sets the playerhealth variable to 100 on each frame. Either set it as a default value with the editor or put it on the top with an at the beginning condition.