I try to put a “Print string” just after the “Player Enter in Cube Trigger” :
When I put “replicates” on “Run on owning client” I have two prints : one from client who enter in trigger and on from server,
When I put “replicates” on “Run on server” I have only one print from server.
My idea is the client who enter in the trigger it calls the server which decided if the box have to change color or not and command all clients to change…
So I think I have to replicates my event only on server (“Run on server”) but I can’t have any information about the client…
The Client can’t launch an Event from Server here because he does not own the Cube, the Server does. And if you look carefully beneath the “Replicated to Server” notify on your function call there is a ‘if owning client’.
You want the Server to Multicast the new Cube color or to switch the value of a RepNotify variable when one player enters the area.
The idea would be:
Begin overlap -> Check for authority -> If authority, cast to player pawn, get the color you want and Multicast an event that sets the new color.
On the server, in multiplayer, the index of GetPlayerController, GetPlayerCharacter does reflect only the local controllers, it will contain them all.
So in your case, when you ask for GetPlayerCharacter with index of 0, you get the player controller in that same index.
Also, makes no sense to GetPlayerCharacter in dedicated server, since dedicated server has no player locally controlled.
What you could do is to:
Cast OtherActor to APawn (or ACharacter) - Here you get the pawn / character which entered the trigger
Get the controller from the pawn /* character using GetController method - Here you get the owning player controller (if any, could be AI controlled) and cast it to PlayerController