How to get this overlap event to work for multiple players

I have created an overlap event which counts how many time people have entered it to prevent giving additional experience after the first time.
What I want to do now is get a reference to whom entered and the counter entered variable only effects them.

[ EXAMPLE ]
Step 1: Player 1 comes along and triggers the event, gains experience and the counter entered is set for them.
Step 2: Player 2 comes along and triggers the event and ALSO gains experience and the count entered is now set for them too. etcetc.

Basically I want any player to enter and gain the experience once, but no duplication experience for reentering if you have already gained experience. Any ideas?

Hi there,
Perhaps this helps:

1 Like

Thanks for your reply mate, I adapted my own code and wrote yours in.

It still is not working, I am not ovely familar with arrays yet either so I am hoping the part I highlighted is the correct pathing method as I need to input a reference into my custom event for the actor.


I forgot to add the highlight lol ^.^

No problem, try to use Add Unique and see if works. Another option, from Other Actor, get controller and create an array of player controllers or player states. If you are targeting multiplayer, also double-check the replication logic for the variables. And the actor itself should replicate.

I played around since you advised about making arrays with the player controllers. Issue is when I use a GET and then pass that into the Update Experience Server node. It does not find either player (testing with 2 ATM) So neither gain experience, I know there is something small I am missing but I am not sure what

Great, you are almost done. it has to do with replication. Perhaps, you should call an event replicated on server, then call another one replicated type of multicast. Another option is server + owning client.

Another possible area is sending this event to the (EDIT) game state and then let this class call server + multicast. From there, you can get all connected controllers and check consistency. Game state exists only on server and replicates.



This is what I have at the moment, it is not a replication issue I am sure. I just don’t really know how to store the player controller and actor both to use to figure out individual players ← If I can figure that out then I am set. Thanks for your help anyway, gave me a few ideas :slight_smile:

Hey @vRaven1! If I’m cherry-picking an issue you noted in your last post, I found some documentation that should be useful!

“I just don’t really know how to store the player controller and actor both to use to figure out individual players”

Player state is generated upon first replication tying player information together and is replicated. It’s often use to check against which player is which.
image

Hope this helps, let me know!

Is this how you use it?



This is the closest I have been now.

When Player 1 enters they are given experience. When they re-enter they do not get
experience and it prints their display name for proof.

When Player 2 enters they are NOT given experience, but the print does not display until they have left and re-entered meaning the array is storing correctly. So what is the issue with player 2 not recieving experience?

Hi there,
I believe is more a replication issue, and it all depends on your game logic. Generally speaking, you want to check if the player controller is a “local controller” and is a “local player controller” (not AI). This prevents the host player (on server) to overwrite other players. Also check replication of the array variable and the actor blueprint itself.

In the Custom Event Update_Client, I set to replicate on owning client, but you want to try also as replicate Multicast.

Unfortunately, I can’t help you much with replication, as is not my expertise, so let’s see what other devs would recommend.

Did you solve it a=i also face issue in my project and google it and found your thread.

Kind of, if I remember correctly player controller is null for online clients. I know you can get the player’s pawn with Get Pawn and that’s replicated. Tying that into your system however would go a bit differently.

1 Like

The clients do not get experience from entering at all even if they are first.
Get null error.
I have also tried changing the Character input coming out of the Update Experience nodes from actor to controller and back and forth and neither work. Everything is ticked for replication, the same as the blueprint.
3


Have you tried running an actual event or something, maybe a print string to test if it is working for yourself too? I know my experience system is completely replicated so it has to do with this blueprint somehow lol

bump

This works if you remove the check for isPlayerController and isLocalPlayerController. Just plug the get controller node straight into the contain node, add node and the end function.

Cheers mate :slight_smile: Thanks for helping me over the past few days!

1 Like