To set the stage, I’m trying to develop a card game. The game starts without any cards or decks (these are the actors I need to spawn) on the map so that the player may spawn these in when ready. I’ve tried various places in Blueprints to spawn these cards, but haven’t found a solution that works in multiplayer. I don’t really want to spawn the starting decks in the World Blueprint because I want to transfer the logic to other maps in the future. Here is my current setup:
- Game Mode - Only character spawning logic in here at the moment.
- Game State - I wanted to spawn the starting decks once (with replication) so I put the spawning logic in here.
- Player State - Not much here currently.
- Player Controller - Player input logic here.
- Player Character - This is where I spawn cards for each player’s hand. It also controls how the cards move via timelines.
The problem is, whenever I cast to the player state or game state and save them as a variables, the client’s (it works fine for the server) variable is blank in the Player Character. To give an example, the Player Character BP attempts to draw a card from their deck so in the Player Character BP I edit all the required variables (such as which card I draw) then I cast to MyGameState to find out the location of their deck so I can spawn the card there and move it to the player’s hand. But the client has a blank variable that refers to MyGameState and it doesn’t work.
Am I setting this up right? Or perhaps, should the Game State be handling the card movement? Or something else entirely?
I can post pictures later if needed. Thanks!