Get player ID from character blueprint

Hey guys,

I have a Ball Blueprint which takes some parameters. One of them is the Player ID, that spawns the ball.

Here’s my setup in the character blueprint:

This is my level blueprint:

The problem is, that when the server spawns the ball, when the event fires in the Level BP, it increments all “Points” variables of every player, including itself.

When the client spawns the ball and the the event fires in the Level BP, it increments all “Points” variables of all players, except the server.

Why is this happening? Doesn’t the PlayerState hold dfferent Player IDs for each player? Or is it because I’m calling it from the Character BP?

I’ve been trying to solve this 2 days in a row… No luck.
Any help is appreciated.

Thanks.

i got a way that is a little more redundant (client executes logic to himself, trigger the event on server (along with his playerId), server to replicate all, replicate all compares to playerId and excludes if the Id is the same as initiator) but using switch has authority basically so in theory, the problem isnt there (i assume you got your spawn ball working everywhere). so yes, you might be doing something wrong on the level blueprint, not because it is IN the level blueprint but the logic that triggers it. could you post a slightly bigger screenshot of it please?

sure here it is:

i dont think that overlap is communicating with the server at any point. what i would do is after the BeginOverlap is fired, send OtherActor to the server (Add custom event, Replicate On Server). After that, the server adds the point to the Points Variable and that variable should be Replicated. once the server does the change on the variable, it should be updated to every player…it confuses me that you are firing the event on the map level. why dont you make the trigger a BP and code it from there?

you tried sending it to a ReplicateOnServer? post the new screenshot. also remember to select Replicated on the int variable Points

I did tried to make the trigger a BP, but I was faced with the same problem, I can’t update the clients individually. How can it be done from there?

how would the server know, when replicating, which player’s points to increment? If I use the PlayerID variable that I have in my Ball, it won’t work because the playerId is always the servers for some reason. When I get it before replication, it displays the client ID, when I replicate it, it shows the server ID, even though I sent it the client ID when I fired the SpawnBall event, which is replicated to server(first image in the post)… It got me pulling my hair out. Unless there is another way to incement the points for each player without using their ID, which so far, it eludes me.

you have to set on replicated on the playerid on the ball too

this is a very simple example. try to copy it and check if it works. hopefully i could catch my point with the screenshots…you spawn a ball (it has a box collision component). anytime you walk into the box collision, it will detect you, announce the playerId stored, tell the server to add a point to the overlapped actor and the server announces the new score.

now, i know you dont have a reference to the overlapped actor but you got the playerId stored on the ball (which im trying to make a point on my screenshots, showing that the variable is being passed). you can do a gamestate->get player array and a for loop to compare each playerstate the array gives and compare it to the playerId.

will try it tommorow and let you know

I tried to copy it, and when I was getting the player ID → PlayerCharacter → Cast to FirstPersonCharacter, the cast was always failing and I was wondering why… And then I say to myself… Hmmmmm when I create the Get Player Character Node, it wants a Player Index… I was feeding that player Index with the PlayerID, which I thought that was the correct way… But then I say “What if instead of the PlayerID, I sent it the Index in the PlayerState Array in which it was found”… GUESS WHAT… IT WORKED. IT WORKED GOD DAMMIT.

This was the reason from the very start that my program didnt work… I was feeding it the PlayerID in the Player Index instead of the actual index in the playerstate array… NOONE TOLD ME THAT THESE TWO WERE DIFFERENT. COME ON GUYS.

This is very crucial. Everyone says “Its ok, just get the player ID and then get his character”… THIS IS VERY MISLEADING.

THE PLAYER INDEX IS NOT THE PLAYER ID!!!
EPIC GAMES SHOULD CHANGE THEIR NAME TO
“PLAYER ID != PLAYER INDEX”

Phew, that was…mmm… refreshing…
Anyway thank you very much for your help…
I really appreciate it… Stay safe.

This is unbelievable, this thread is ONY ONE place that says way to get id to use in getPlayerController|Character nodes, which is really often used ones while u.e. have at least 3 different ids which named “player’s”.

… dude, can you put your final blueprint here … i experience same issue… need a unique ID of player.

If i understood correctly the thread says that you should use “find” in gameState"get player array"(node) to get “player id” (which you ,for example ,can use for “Get Player Character” node)

I figure it out this way and its working fine:
I add “TextRender” component to my third person character.

Then I used “PlayerState” variable which exists in Pawn as variable and it gets updated on all clients. This PlayerState provides a couple of useful variables like “Player ID” which again, is updated on all clients and it “is” unique.

So I put this in my TextRender on my character, here is the result.

Then I assign Z key to set text box to a string as text, so when a player hit Z key, the TextRender will change from client ID to a string and, it will be visible on each client. For this functionality, I did:

A- make and call an event on the server to send PlayerID to server

B- make and call another event to send PlayerID again, but this time send that PlayerID as “Multicast”.

C- then, compare PlayerID, which I received, by PlayerID that I have from “PlayerState”. If these two are equal, TextRender will print the text on each client.

After running 3 clients (and make then sorted on camera!) , I chose Client 1, and pressed Z, the string only comes up on client id 263.

… check my latest comment … ; ] ,