Download

What is the proper way to go about this?

I’m making a simple board game which includes a deck of cards.
I currently have the following C++ classes:

  • ATPDefaultGameMode (derives from AGameMode)
  • ATPPlayerController (derives from APlayerController)
  • ACardHandPawn (derives from APawn)
  • ACardDeck (derives from AActor, behaves like a UInstancedStaticMeshComponent)
  • UPlayingCard (derives from UStaticMeshComponent)

In my project settings, I have set the Default GameMode to be TPDefaultGameMode.
I have also set the default pawn class to None and the player controller class to TPPlayerController.
That being said, ATPPlayerController::SetupInputComponent() is responsible for binding input actions to methods found in various classes.
For now, I only have the ACardHandPawn:: DrawCard() method set up, and it works as long as I actually spawn an instance of the class beforehand.

Now here’s where it gets complicated… Instead of explicitly spawning a pawn class into the world, I would like to be able to place 4 pawns in the world (via the editor), and assign controllers to them (via the editor and/or C++).
The reason I would like to do this is because I have a separate animation class which performs linear transformations from point A to point B, and it just makes more sense to set the initial transforms in the editor.
My first thought was to add an ACardHandPawn actor reference to the player controller class as a UPROPERTY variable, and then just assign it to the pawns I add in my scene.
But 2 things go wrong… First, the reference never gets set. The drop-down list just says “None” after I try to set it to one of my pawns. The second issue is that this is going to be a 4-player game, so perhaps having 1 player controller assigned to 1 of 4 pawns is actually not the best way to go.

So my questions are:

  • What options are available to me to properly set up a multiplayer, turn-based card/board game? (There will also be single-player vs. an AI)
  • How should player input be decided (keeping in mind that ATPPlayerController::SetupInputComponent() is responsible for action bindings to other classes)?
  • Are blueprints really that necessary for a simple game like this?

Never made a turn based game but my approach would be letting the game mode decide who’s turn it is and call an RPC method to enable/disable the player input on the controller (PlayerController/AIController)
When u draw a card, locally check if the input is enable, if enable call an RPC for drawing the card. The server RPC handler should also check if input is enabled to be sure.

Maybe add a BeginTurn/EndTurn to the controller.

Blueprints are not really needed, at least no blueprint “programming” if u do in c++, u will always need a bit of blueprinting like making your pawn BP where u set the mesh and stuff.