Hi, I am trying to get the PlayerID from the hit event in a multiplayer game I am working on.
I have a projectile and I would like to get the instigator PlayerID and the hit PlayerID. I am able to get the instigator playerID fine. but I am having trouble getting the hit PlayerID. The reason I need the PlayerID is because there is a chance players can have the same name. I am using steam API. I have the collisions set up correctly, but cannot workout how to get the playerID from the on component hit (collision) event. I have tried breaking the hit pin and using hit actor, but i cannot work out how to get the playerID from that, hopefully I am not missing something simple.
Any help is welcome, thank you.
You do not need Player ID at all in this scenario. Player names do not have anything to do with actors that are placed in the game, each actor will be uniquely identified anyway (irrespective of Steam API or their “display name”). You can pause your game, jump into respective blueprints and have a look in the Debug Filter to confirm that. When you retrieve the information just use actor matching. You should be doing this on your game server anyway so you don’t have to worry about tampering.
Another reason i wanted to capture this is because I have a stats array which hold various stats of the players, and this array has an index based around the playerID.
I have read other similar posts where it seems a better solution is to monitor player controllers joining the game and to assign them a playerID created by the game (and not the steam API playerID), and then use that in logging stats etc. I have also read that playerID from steam is not actually that reliable in multiplayer games.
Player ID is stored in Player State, not on the Pawn. You will not be able to ‘break it out from hit event’. You can get Player State from Player Controller. So Pawn (Character) → Player Controller → Player State → Player ID.