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.
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?
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.
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.