Hey everyone! I’m Creating a Pokemon Style Game where everyone joins a dedicated server and can run around together. I have a list of Nearby players that you can invite to Battle and Trade.
However I can’t seem to get it to bring up the widget to accept or refuse the battle. If I click the battle button currently It sends the invite to the player who sent it. I tried to send the selected players state/controller to the Game State to then run it on the server.
If anyone has any ideas how this can be resolved you’d save me a lot of sleepless nights ahha
Clients can’t execute multicast RPC’s so On Clicked calling FindPlayer on The GameState will not work.
You have the right idea of using the PlayerState though since each player own their own PlayerState and can use it to send RunOnServer Events from here and every player can get a reference to all the other PlayerStates.
I would avoid the GameState in this and also avoid PlayerController references as they are not replicated to other Players.
So you could create a RunOnServer event on the PlayerState which sends the Playerstates of the opponents you want to battle and then the Server can forward a RunOnOwner RPC to the PlayerStates that needs to know so they can get a Widget pop up.
So I have tried to implement what you’ve said and now instead of the invite appearing on the senders screen it appears on everyones screens. So i feel like there is progress happening at least XD haha
I feel like maybe i’m not pulling through the Player State correctly?
If you use replicated variables then you need to set the Replication Condition of the PlayerState variable to OwnerOnly but it might be easier to just use RPC’s
So this is how I’ve set up the Player state (Removing the Replicated Variable) and I’ve now got a Client Invite that runs on the owning Client. Now its back to showing up just on the senders screen
Sorry to bother you again. I am currently working through the Accept Battle code. I wondered if I could pick you brain again. Im basically wanting the Invitee to click accept and then send each others teams to one another for a battle.
I feel like im pretty close to getting it working but currently when I click accept nothing happens. Any help would be appreciated
To get the BP_ThirdPersonCharacter from a PlayerState you should not use GetPlayerController and then GetOwner as this would not return a Pawn. Use GetPawn directly from the PlayerState instead.
“Accept Battle Request” also don’t need a Parameter of the JoinPlayerState as this is the same as the Target “self”.
You have a lot going on the “Accept Battle Request” event but at first glance it looks alright.
Thank you so much your information has helped me get them through to the Battle World the only problem i have now is their team information comes through blank
That worked a treat! Thank you again for all your help! I can now finally get stuck into replicating all the Battle Mechanics and move forward with my project