I’m testing my health system, I have two spheres, when I’m inside one, I want my health to decrease by 1 every second, when I’m in the other sphere I want my health to increase by 1 every second… But currently, I do not know how to get them to change my health incrementally, they only do it a single time when I enter a sphere. And I have no idea how to get the script to recognize the difference between the two spheres, as currently, both damage the player.
How to get the "EventActorBeginOverlap" event to tell the difference between two actors.
First, to separate the action, the simplest way to do it is to have the spheres contain a script that damages each actor once a second, rather than have the character test whether it’s in a sphere and damage itself.
Second, the simplest way to implement this is for each sphere to have a timer that fires 1 time per second, and for each actor that’s in the sphere when it fires, add/remove health to it. The sphere should have a set of actors in it (an array or a set or something.) In the Actor Begin Overlap event, add the actor to the set of actors in the sphere, and in Actor End Overlap, remove the actor from the set.
You can also make how much health is added/removed per pulse be a configurable variable on the sphere blueprint.
Yeah, in hindsight, attaching all of the scripts to the player rather than the spheres was a bit of a mistake. I have little experience coding (I used to do a tiny bit of Lua but that’s about it), so I’m just trying to cobble something together that works, based on what I can intuit from the names of the various code blocks.
Alright so, this is what I have so far for the sphere, but for some reason that is beyond my understanding, it still isn’t working.
Create a Enum and Add the enum as a variable and click the eye so you can set it in the editor.
Build a small processing loop that is safe
Interesting, I’ll compare it to the script I’ve made so far and see if I can finally get this to work.
You haven’t hooked up the execution output after the cast to the set and the print.