Download

Trying to make a Healing Area/Zone For Multiplayer.

Hello, I am trying to make a healing Area on my game for multiplayer. Basically a medic can place an Item on the ground and Players on his team will begin to Regen health if they are in the area. The issue I’m having using a timer is that when any team player exit the area it stops the timer and healing for all other teammates in the zone… The healing part works fine its just when somebody leaves the area it stops the timer/Healing for everybody else still in the zone. How would one solve this?

Code doesn’t look instanced… The timer is just a symptom of the larger issue. Why not put the ‘active code’ (code after the overlap event node) into its own BP (Health Regen BP) that can be spawned with a character reference passed-in / exposed on the spawn actor node. Otherwise this is going to run as one instance for all players all of the time, which won’t end well… Look at that or create a dedicated sphere regen BP that can placed or instanced in-level (and doesn’t overlap). Make it so it can only be triggered by one player at a time (Gates or Bools to lock the sphere BP etc).

@ClavosTech Is absolutely right… There are no fast answers or fast get up to speed with multiplayer.

If you’re trying to make a multiplayer game, you must understand the paradigm of writing code for multiplayer. The server is the authoritative source and anything that happens in the game that everyone needs to either see (anything physical like transform data, textures, shaders, colors, bullets, particles, etc) are usually Multicasted (everyone gets the update), or some client needs an update to some attribute: (health increase/decrease, speed), usually done different ways (RunOnServer or RunOnOwningClient). The thing to wrap your head around is that everyone uses the same code, so you must identify what variables/actors need Replication, how to fire Multicasting, how to use Run On Sever (because clients don’t have authority) to forward to a Multicast event, and what events need Run On Owning Client. https://docs.unrealengine.com/en-US/…nts/index.html

To understand this concept, begin with the gameplay framework (gamemode, gamestate, playerstate, playercontroller). This hierarchy of classes are up to you how you want to use them, but they are [virtually] mandatory in some way when developing for multiplayer.

The second ingredient is event based code. Whenever something needs to be updated through multiplayer, events are the key. Events are set up to do one of three things: Multicast (broadcast this event to everyone), RunOnServer (if you are not the server, then this configuration runs the event on the server), and RunOnLocalClient. If this is a school project, this is not the time to learn multiplayer. However, feel free to watch this short video to give the most insight in the shortest amount of time. Though, this only covers about 10% of usual multiplayer needs https://www.youtube.com/watch?v=9IQT1y_Q2RY.