Make a dual game, where do i store variables for each player and interact between them ?

Hi everybody !
First i’m a beginner with UE4 and i watched and read lots of tutorials. (I’m not English so sorry if i make some mistakes)
Now i want to make my game.

It’s a “dual” card game, one player play against another player. Both of them have the same interface but each player has their owh card. (Like Clash Royal for example).

So i make a prototype of the interface with sprite color (nothing work, it’s just color don’t worry) then i add a widget. You have 3 screens, when you press one of the 2 button of the widget you move to the right or left other screen.

(In this picture you can see the 3 white screen)

(here you can see the two UMG buttons)

SO, all work well, the camera move bewteen the 3 screen. Then i want to duplicate the “interface” for the other player (is it the right way ??) and now nothing work… The camera don’t move for each player…

So my questions are : what is the right way to do someting like this ? Do i have to use something like pawn instead of camera ? (I don’t know how to use pawn) Where i store variables for player ? Because if you are the player 1, the ennemy life is the life of the player 2. And if you are the player 2, the ennemy life is the life of the player 1.

This is my Level Blueprint (if this can help you)

And here my gamemode Blueprint (empry, only variables)

I hope you will understand me, if you want to ask me some questions if you don’t understand you can. I’m beginner and i really want to learn how to do a game like this on UE4. Tank you :slight_smile:

you dont need to duplicate the board, you do have to understand client-server replication, add different player starts and make a pawn static, just camera view. i suggest following the multiplayer shootout tutorial, or even BlenderTek’s multiplayer tutorial in youtube (he does the same but explains a little more). basically you filter the executions depending if you are client or server (if its 2 player only, if its more, you have to work with playerid stored in player state of each player)
it’s not hard once you understand. but you have to change your approach. its pretty much like duplicating how it works in real life, 2 players (pawns) , 1 board, and the networking is the communication channel between them.

just remember this. gamemode is only accessible from server, game instance stores values throu all game, client and server. playerstate is unique and for each player, also, it replicates by default across the game to everyone (use this to share information), game state is useful to store current game data and could be used like a game instance (i might ve wrong here but i pretty much use it this way)

Thank you a lot to answered me very quickly. I’m looking for this 2 tutorials and i don’t forget the end of your answer.

But i don’t understand how the players can have their own boards with only one board ? The two players must have their own board beacause it’s the same interface but no the same card on each board? Maybe i don’t understand something ?

depends on how you manage your replications. you can replicate all movements and animations just like you can set certain animations, values and movements depending on the player.

to filter who gets what, i pass the playerId and on the multicast, if the reciever is the player who initiated the event, he doesnt gets the replication (for example). you can also make the initiator execute a logic for himself and on the broadcast, tell the server to execute something different (like keeping the cards upsidedown so the oponent dont see it)

Im not that experienced to be honest, so be careful with my blueprints. so far, i try to apply the tutorials i see and im guessing the replication could be handled even better. but this should be a start for you.

IsThisInitiator is a macro, everything happens in the same blueprint but its not needed to be like this, you can use blueprint communication depending on your needs.

Ok thank you very much for your s=answers ! I will look all of this during this week end! :slight_smile: