I am trying to make a board game in UE4. So far I have 4 pawns spawn in a starting area. There is a button on screen that rolls a die. Whatever number the die rolls, the pawns move that many spaces. Right now though, all 4 pawns move that number at the same time. How do I set the pawns to be their own player and how do I setup the game so that player 1 takes their turn, rolls the dice, moves, then player 2, and 3 and 4. Do I create a MyTurn function and somehow have the pawns call it when it should be their turn?
Image 1= my board where 4 pawns spawn. Each pawn has a player start tag but uses the same BP.
Image 2= Moves the pawns according to the dice roll.
Image 3= Spawns in the 4 pawns at the start.
hey,
its a singleplayer game right ? okay lets dig into this.
first of all you need some sort of a brain in your game that decides what the current state of the game is.
therefor i recommend you the basics of the ue4 framework:
[Setting and Tracking the Rules of the Game][1]
i would stuff all the information into the gamemode/gamestate related to the Rules of the game like
Players
scoring
etc.
from there you can start building up the brain by thinking about the turn based flow of the game. something like :
→ you create a intro level which loads up the menue UMG where you set up your players (i think u have done this by now)
→ then u load the new map and spawn those players like u did here and reference the controllers to an array in the Gamemode
→ when everythings ready the Game mode goes on by making a custom function like “start round”:
→ it start at the player array index 0 (so player 1) and tell him to roll the dice. you could store that current player in the Gamemode as well to get a more easy access to its index.
→ then the Gamemode creates an UMG where you can roll the dice. then u can go :
→ PawnReference → get player controller → simple move to actor (which is the plate , that has a number tag or how you want to identify it as the number you want to reach ), it should only let the pawn walk that is referenced in the gamemode , you can do this also by just setting the current players index and refer to the playyer array if you’re more comfortable with this.
→ after he reached its last plate , the turn ends , this means:
→ it adds +1 to the current player index , checks if it is more than the last index of the player array (for a new round) , if not the whole thing begins again from the beginning.
for a more structured way u can also make enumerators and call a switch on int node:
Thanks for the info! Very helpful. I would like it to be a multiplayer game. Does that change how I set this up? Would each pawn need their own controller? The wall I’m running into is how to reference the correct pawn when the round starts and ends so the next pawn can go but to make sure they go in order.Ive never used enumerators. Would that be easier to follow you think?
Hey I don’t suppose you’re still active on this thread are you? I’m just starting to look into exactly this, moving spaces according to dice. I have a couple questions about your BP.
I’m so all over the place with UE, but yeah mostly been working on an aesthetic for it. I still don’t know how to get the pawn to move according to a “dice roll,” but that mechanic would open things up for me.
ok so yeah i have it done where a dice is rolled and a game piece moves accordingly to spaces. its pretty complicated and has alot of blueprint work though. What kind of game are you workin on? how are the aesthetics lookin?
My thoughts are a “board” that looks like America. Kind of in Oregon Trail style, the players progress from East to West with a handful of different paths they can take. Depending what space they land on will trigger an event (hunting, resource gathering, combat, etc) and open a mini level. Whether it be dice, a spinner, or some other random number generator, something will determine how many spaces are moved.
I’m playing with different aesthetics, right now I’m digging a hexagon grid, with the tiles around the paths set up to look like miniatures or dioramas. So the movement aspect will be top-down over the board, with the levels turning to third person.
I just don’t know enough yet to make the random number move the pawn accordingly. I’ve looked a little at the Advance Turn-based Tile Toolkit on the marketplace, but don’t want to pull the trigger unless it’s my best option.
ok cool. Mine is more like mario party. Roll a die, move that number of spaces. idk if ill do minigames or not, maybe more of like a classic board game. having trouble with the camera view right now, then just probly design. So how much do you have for the dice movements? How much do you need?
Well I feel like I’ve fried my brain trying to figure out the best approach. My thinking is like yours, roll the die/dice and move that many spaces. Only I’d throw in a few opportunities to choose between a couple paths (if possible).
I guess I’d say at this point I need someone to tell me like I’m 5, lol. I can get around the engine, I’m not a total noob, but this has me stumped. Any help would be immensely appreciated!
I’ve also been looking at camera views, but haven’t decided exactly what I want there. I’d love to hear or see updates on your game!
Kind of both i guess. The tiles are numbered. So the dice gets the number thats at the highest point when not moving and thats the number thats rolled and then the piece is moved acordindg to that number by checking what space its currently on and adding the number that was rolled by the dice,
That’s the mechanic i can’t figure out, lol. Roll a six, move six spaces. Seems like it should be simple but i might not know blueprints well enough.
@UnderBigSky
yeah goodluck. And for the actual game spaces, i just created a new blueprint of a square and added an integer variable called SpaceNumber so the pieces know where to go next.