Good day to you all!
I was looking throught the forums to find a solution to my problem I was struggling with for few days now and couldn’t find any! As you probably already know, I would love to get help with switching players in local multiplayer top down turn based logical game.
To make a better example, I’m trying to create similar player system to the Heroes of Might and Magic series (local multiplayer on one computer; each player plays different type of nation, which determins their style of play and style of meshes they control/spawn; stores camera position for each player). The only difference is, that I don’t want players to end their turn after they click button specificaly created for that purpose, but actually automatically right after they finish they turn (which is explained further, very simple gameplay).
I would like to switch players, who take turns always in the same order (from 1st to 4th), right after they make they turn. Turn consists JUST of clicking on one of the TreeActor stored in Board Objects Array, which is stored in GameBoardGrid. (Similar to the logic puzzle board game example in the UE4 marketplace, just with taking turns right after they click on one of the actors).
So, all my current blueprints are:
- 4x Pawn - One for each player. Contains camera component attached to spring arm, stores the location of camera for each player while he/she waits for his/her turn to come.
- 4x Controller - One for each player containing wanted controls chosen by each of them.
- Game Mode - Currently has no nodes inside. In the future I would like it to contain number of active players, their attributes, etc. and spawn appropriate number of pawns and controllers based on the chosen number of active players and their choosen nations.
- TreeActor - Contains static meshes in the components tab; so far the only blueprint that recieves input from the player - just basically simple onClicked on self, which makes appropriate objects stored in the components tab visible. Appropriate objects are choosen by the type of nation current player plays.
- GameBoardGrid - basically just a for loop node, turned on right after the game level loads, spawning TreeActor 1200times (to fill the my 40x30x grid; size is set) with appropriate offset (which is also set) and placing each of the spawned object to Board Objects Array with their own specific index (from 1 to 1200). It also tells the appropriate TreeActor their own index, but I’m not sure If that’s necessary for now, I had it there just for testing purposes to print Specific Index after player clicked onto one of the Tree Actors.
- GameLogic - Empty so far. But it will be checking who is currently in the lead after each turn and will take care of all the mechanics influencing players like random event happening on the board, etc.
My problems are:
-
The only blueprint which can change pawns is the Level Blueprint (as far as I know), so I really don’t know how to get the input of clicking onto one of the Tree Actors into Level Blueprint to trigger the pawn change without casting into it.
-
The change of players needs to be casted back to all the spawned Tree Actors so they now which player is currently in control to determine his/her nation and I’m not sure how to acomplish that. Maybe by getting the current pawn/controller and deciding based on that? Sight, but that gets me back to the first problem.
-
Is my current blueprint setup and their future planning done the optimal way? I do 3D graphics, it’s the first time I’m actually doing some visual scripting, so please, If you know how to do this any better way, let me know.
Let me know If you need more info, screens of the blueprints or any anwers.
Thank you all for you help, I really appreciate it.