x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

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

alt text (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...

alt text

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)

alt text

And here my gamemode Blueprint (empry, only variables)

alt text

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 :)

Product Version: UE 4.11
Tags:
1.png (169.4 kB)
2.png (33.6 kB)
3.png (48.0 kB)
4.png (260.8 kB)
5.png (146.9 kB)
more ▼

asked May 23 '16 at 09:07 PM in Blueprint Scripting

avatar image

ValMineFirst
7 2 2 5

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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)

more ▼

answered May 23 '16 at 09:28 PM

avatar image

jblaswu
808 21 11 46

avatar image ValMineFirst May 24 '16 at 07:48 PM

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 ?

avatar image jblaswu May 24 '16 at 08:27 PM

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.

alt textalt text

mp_cards2.jpg (196.4 kB)
mp_cards.jpg (1.1 MB)
avatar image ValMineFirst May 25 '16 at 08:47 PM

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

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question