Download

Health percentage before and after respawn

Hey , I’m making a platformer, there will be a bunch of platforms moving around and under them spikes…I made those spikes with overlapalldynamic collision so when player falls and overlaps them he spawns at last checkpoint, now the problem is : that collision also takes away 20% of character’s health but when he respawns that health goes back to 100% because begin play event sets is to 100%…how can I make it so that collision takes away 20% and respawns the player with 80% not 100%? Please help

You could notify the level blueprint when the player respawns and then modify the health from there.
So it would be something like this:

  1. Player falls on spiked platform
  2. Platform tells level BP to reduce health on respawn
  3. Respawn player
  4. Reduce player health from level BP (from the same code/nodes that you used to respawn the player)

HTH

Thank you very much for your reply, something like this? Please tell me to correct any mistakes if you see them because I’m a beginner :slight_smile:

That is pretty close.
I would handle the respawning at the same time as the trigger overlap.
Move the nodes from the levels “Tick” event to the overlap event of the spike platform.
So the spike platform overlap event casts the “Other actor” parameter to your player type(“GumbCharacter”) and calls the “Respawn Player” function.
Then it sets the player health variable of the player, But you have to set health variable to “Editable”(The eye next to the variable in the list).

I can do a mock up for you if you don’t come right.

There a twitch training stream talking about blueprint communication here that you may find useful.
I have not watched it, But it will probably be good if you are not familiar with different ways to communicate between objects in a (programming) language.

HTH

Again, thanks for your reply…’‘So the spike platform overlap event casts the “Other actor” parameter to your player type(“GumbCharacter”) and calls the “Respawn Player” function.’’ I don’t really get that part…

Unfortunately, I won’t be able to setup some nodes to show this.

The trigger box on overlap event node has a parameter called “Other Actor” on the right below the “Exec” pin, Drag that pin to the “Object” pin on the left of the “cast to” node.
There is a AI tutorial in the wiki/doc that will show casting there, That should help with that.

Here is a example on how to connect up the trigger cast nodes.

YES, got it…thanks a lot !

Your welcome, Just post back here if you have any further problems.