Turn-Based Local Multiplayer Logic

Hey guys! I’m making (like the title states…) a turn-based local multiplayer game and have some doubts about how to setup the turns logic. I’ve searched for similar topics on the forums but couldn’t find.

So, how do I go about setting up the turns for two players? I have one Player Controller controlling two pawns (actually it’s currently controlling only one hehe). I’ve setup Action Points and each time the pawn moves 100units (1 tile) it spends 1 AP. Once AP is zeroed out, I’ve setup some bools for isPlayer0Turn and isPlayer1Turn and alternate their value. Don’t know how to make the Controller control the other pawn when the turn shifts. I’ve set up the players indexes (player 0 and player 1) but not sure how to use them (e.g. increase and subtract on each player’s turn). The input is going to be only touch, so it has a single button on screen to play the dice and the pawn moves automatically.

Here are some screenshots:

Overall Project
e6d8ada6ce8ca443c3b8a7609ae31700b70be5ac.jpeg

Player Controller Graph

Function inside PlayerController for moving the pawn

593868dbceead9eea0d96651e1002adfec36af57.jpeg

That’s it, thanks a lot guys! =D

When one turn ends, you’ll want to depossess the current pawn then possess the next pawn.

So, when I unpossess, it breaks the view, probably due to my camera setup (in Level Blueprint, Set View Target with Blend asks for a Player Controller and it comes with index 0). How to solve that?

Thank you very much!

Found a solution here: Possession of Pawns - Unreal Engine 4 Blueprint Tutorial - YouTube

Trying to make it work now.

What is your current camera setup? Do you have a camera attached to your pawn? If so, you should remove it. Just use a camera actor in the level for this situation. Set View Target With blend on Begin Play and just use “Get player Controller” with index 0. This way when you change possession your camera will not change, or at least it shouldn’t.

I did that but the camera changed because my pawns have different indexes, so when the controller possessed pawn with index 1 it would break the view. I simply attached two “Get Player Controller” on the Set View Target with Blend, one with index 0 and the other with index 1. It worked and the camera is fixed =) Don’t know if this may cause some other problems, but none so far.

Thanks a lot Jared!

You’re welcome! I think you can simplify this though, you don’t need multiple PlayerControllers - since the game is pass and play, you can do it with just one that hops between possessions.

Actually there’s only one Player Controller, but I put 2 “Get Player Controller” nodes attached to Set View Target with Blend, with different indexes. =)

Then the engine is trying to get another player controller that doesn’t exist. If you haven’t created more players then there’s only the single controller at index 0. I haven’t looked at the code so I don’t know for sure, but I assume there’s a fallback plan where if the higher index doesn’t exist, it’ll grab the highest index or index 0. If it works, it works, I’m just offering some insight as best I can. :slight_smile:

Hmmm I see. I’ll keep that in mind in case I get into other issues. o/