Simple Board Game movements (NOT CHESS)

I have been looking for weeks now trying to find info on how to move a pawn on a simple game board. I have dice set up so I want my pawn to move around a board according to the outcome of the dice roll. Does anyone know of a good video to follow or is this to simple for UE5?

That’s a pretty broad topic and many ways to do everything depending on whether C++ or Blueprints driven game. Research each of these general topics:

  • create pawn
  • create an AI controller for the pawn
  • create a navigation mesh
  • create some points that sit above the navigation mesh
  • have the AIController order the pawns to move to designated points
  • create a graph out of the navigation points based on game rules, which dictates all legal paths
  • create a queue of navigation points (i.e. a path) for a pawn to follow, based on the graph of legal moves

Individually these aren’t hard. But fitting it all into a coherent game framework pipeline is somewhat challenging.

Thank you for the quick response. I have done the 1st 4 suggestions. I have a dice roll button on my HUD and a pawn blueprint. In my pawn BP I have a next target integer with all 40 target points.
I have character movement set up, I can even get the pawn to move to the start point and if i roll the dice it will go to the points but nothing more. I believe i need a way to have the “Dice Rolled” number move to the next target. Is an AI required?

You can do it with or without AI / navmesh.

What kind of board are we talking about? What kind of movement? There’s probably a dozen ways to approach it all - some may be better than others, depending on what is really needed.

You say it’s not chess. Is it like Monopoly then? Or one of those:

image

Interconnecting paths? 2d / 3d? Or something completely different?


Also, have a look here for something truly generic:

Yes it is like monopoly, a board with 40 spots going around and around. I only have character movement. I want to basically roll dice and move through each target point. If i roll a 10, then i move through 10 target locations then stop. I want to keep moving around the board until the game ends. Its only one direction.


there is no timeline, just roll dice and pawn moves. If someone has a simple example for me, that would be great

I’d use the timeline for this. Perfect example, as in the link.


What I’d really do is to use a spline but manually setting the data may be fine if that is all that is needed.

2 Likes

Easiest thing to do would be to create an actor which represents the tiles, place them on a map in order, then create an array variable somewhere (probably level blueprint) of the tile class. On begin play, you’d get whatever is at array index 0, and teleport the player pawns there and store the index as an int var on teh pawn. Then, to move to new tile, add the dice roll value or whatever to the player’s current tile index (which would initially be 0), and get the new tile from the array, move the pawn to its loc, and update the pawn’s tile index var.

Edit to add: Did this using player controller in top down template:

The BP_TileList class that it gets in begin play is just an invisible actor with a public array variable I can edit in map viewport to create the list of tiles in order. The var type is an actor which just has a cube in it for the tile. Navigation can be a bit wonky with a large roll, but more tiles should smooth it out. I only added 20, so going from, say, 10 to 2 with a 12 roll ends up with char going backwards on the board. Might be best to use spline movement and draw the spline so each point is on a tile…

1 Like

Spline or not I think the important thing is using an int to keep track of where player is on board. If using an array of locations or actors like I did, you can just grab the location from the array at the matching index. If spline you would get the splne vertex by int. And for a looping gameboard like Monopoly, you can use modulu (aka % mod or just %) to loop the int around based on array length or (vert count of a spline), as I did on the array get in the keyboard R event.

Here’s a link to relevant files from my experiment if you’d like to try it. Just make a project based on top down template, and extract the zip to the /content/topdown in the project directory. Not sure if the reference var in the tile list actor will survive the transfer, but you can at least see where they were set in the included map.

2 Likes

Thank you, Ill try this out

OK After 2 months of learning and research , I finally did it. I made all 40 tiles and made them each a vector and set their coordinates. I added all the vectors to a Make Array and used a Vinterp then Set Relative Location. This moved the pawn but it kept going to the number that the dice rolled. So roll a 6 and it would go to 6, then a 2 would go back to the 2. I fixed this by adding a sum variable to the roll dice. Roll 6, pawn goes to 6, roll 10 then pawn goes to 16, all the way around. I added a branch so when the sum was 40 or over it would subtract 40 and the sum would start at 0 again. Works perfectly…Thank you everyone for your help.


I know this is not the best way to do it but with my limited experience, it worked…thank you again.

2 Likes

Nice work. :+1:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.