Announcement

Collapse
No announcement yet.

Turn-Based Local Multiplayer Logic

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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
    Click image for larger version

Name:	Overall.jpg
Views:	1
Size:	152.8 KB
ID:	1200202


    Player Controller Graph
    Click image for larger version

Name:	2016-11-10 (2).png
Views:	1
Size:	457.0 KB
ID:	1200195

    Click image for larger version

Name:	2016-11-10 (3).png
Views:	1
Size:	447.3 KB
ID:	1200199


    Function inside PlayerController for moving the pawn
    Click image for larger version

Name:	2016-11-10 (4).png
Views:	1
Size:	442.1 KB
ID:	1200200

    Click image for larger version

Name:	2016-11-10 (5).png
Views:	1
Size:	541.6 KB
ID:	1200201

    That's it, thanks a lot guys! =D
    Attached Files

    #2
    When one turn ends, you'll want to depossess the current pawn then possess the next pawn.
    Procedural, modular, on-the-fly animation - iTween For UE4
    - Actors - Components - UMG - Ease In - Ease Out - Path-constrained Animation - $0

    Runtime Datatable
    -All the fun of DataTables dynamically loaded from text or Google Sheets while your game is running!

    Comment


      #3
      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!

      Comment


        #4
        Found a solution here: https://www.youtube.com/watch?v=-4j_uGgUaB0

        Trying to make it work now.

        Comment


          #5
          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.
          Procedural, modular, on-the-fly animation - iTween For UE4
          - Actors - Components - UMG - Ease In - Ease Out - Path-constrained Animation - $0

          Runtime Datatable
          -All the fun of DataTables dynamically loaded from text or Google Sheets while your game is running!

          Comment


            #6
            Originally posted by Jared Therriault View Post
            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!

            Comment


              #7
              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.
              Procedural, modular, on-the-fly animation - iTween For UE4
              - Actors - Components - UMG - Ease In - Ease Out - Path-constrained Animation - $0

              Runtime Datatable
              -All the fun of DataTables dynamically loaded from text or Google Sheets while your game is running!

              Comment


                #8
                Originally posted by Jared Therriault View Post
                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. =)

                Comment


                  #9
                  Originally posted by Harry Florencio View Post
                  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.
                  Procedural, modular, on-the-fly animation - iTween For UE4
                  - Actors - Components - UMG - Ease In - Ease Out - Path-constrained Animation - $0

                  Runtime Datatable
                  -All the fun of DataTables dynamically loaded from text or Google Sheets while your game is running!

                  Comment


                    #10
                    Originally posted by Jared Therriault View Post
                    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.
                    Hmmm I see. I'll keep that in mind in case I get into other issues. o/

                    Comment

                    Working...
                    X