Godot Version
Godot 4.4
Question
Looking at various documentation, articles, and demos for Godot multiplayer, I’m left wondering how to logically think about multiplayer state. There’s plenty of examples of “just initialize a server, join a peer, sync these nodes/properties, and boom - working game”. A lot of examples seem to hinge on every player seeing the same screen - the scene tree is synchronized between players.
But what if I am looking to have different players see different views of the overall game? I’ve been thinking about a card game of sorts as an example. Suppose each player has a has “deck” and a “hand” of cards. Players still need to join a server lobby to start a game - that seems to be straightforward to do. But what I get hung up on is the how to think about, share, and ultimately render game state for each player.
Players obviously need to know about each out - how many other players, how many cards they hold and the card they play. But each player would not see each others hand, and further-more, while each player’s scene tree would be similar, but each would focus their own hand, not that of others.
In a single-player implementation, this seems relatively simple to do, I can have a scene that is the game view and manager, which would have a scene of the deck that consists of “card back” nodes and a scene of the player hand that consists of “card front” scenes that would be a sprite, a position, and would hold logic for what to do when played. A player hand scene or just mouse events could be used to interact with the various nodes, each of which would be responsible for itself and its effects. ie playing a “card front” would invoke code in it.
But in multiplayer, how does one think about the state? A lot of tutorials just utilize the MultiplayerSpawner, but i dont think that really suitable here? I’m leaning towards considering the state of the game and the client scene tree that the players see as distinct things, which goes against how i would implement them in single player where the sprites, position, as well as logic and behavior is baked in to the same nodes. Especially if theres interaction between players - eg player 1 plays a card that forces player 2 to discard a card - player 1 cannot see player 2’s card, but the clients (and the server?) need to have this back and forth to carry out the game logic across a global game state that different players have different insights into and different control over.
Overall, is there a good description of how to think about and approach a multiplayer game in Godot where the players each have a distinct view and only have knowledge of a part of the overall game state and can enter complex interactions between each other?