GamePlay movement for a board game?

Recently, I decided to create a board game styled place on roblox and so far it is turning out pretty good, however, I got stumped on how you would move players across the different panels.

image

In this board game, players will have a different amount of cards in order to move spaces, the amount of moves available is determined by the card that they play.

However, I just dont know how to detect if theres a part infront of the character. I was expecting to use the :MoveTo() function and I’ve already overridden the characters controls I just dont know the best way to get them to move to the next block.

I’m quite inexperienced when it comes to coding so I usually need a little nudge in the right direction

Any ideas would help tremendously ! Thanks guys!

Using MoveTo is probably your best bet, seeing that you’ve already disabled player movement input.

Assuming this is the kind of thing where there’s different points on the gameboard. Like, spawn, p1, p2, p3. So if the player rolls a 2 he’ll move to p2 from the spawn.

If that’s the type of system you’re using, I think MoveTo would be fine. The only thing we’d need to find out is the point we want the character to move to. Perhaps the best way would be to navigate the player using MoveTo to each point based on the number they’ve rolled. That way, they won’t fall off of corners.

There’s also a handy event you can use that runs when MoveTo finishes running:

Anyways, it’s pretty late and I got to get to bed. I hope this helps to some degree, if you need more clarification or if I rambled too much I can try to assist you further in the morning. :slight_smile:

This is what I need to figure out, I didnt know that :MoveToFinished was a thing so that helps heaps :smiley: but yea, I just dont know how I’m going to move them from one spot to another , or how to detect which way the player is going. I was thinking of numbering them, but I dont know what will happen when the players hit a junction and can go any which way they want

2 Likes

You could store this info in many ways. Personally, I’d take advantage of Roblox’s Values. E.g., using an IntValue to store their position and direction.

I would label each panel with a X, Z value - so for example the red panel on the far left of the image could be [0, 0], then the next 2 orange panels could be [0, 1], [0, 2] etc… This is one way of storing the panels.

Using this system we could create a matrix to represent a grid of all the panels - to initialise such a table:

local width; --how many panels wide the gameboard is
local height; --ditto as above

local board = {}
for w = 1, width do
  board[w] = {};
  for h = 1, height do
    board[w][h] = false;
  end
end

If there is a panel at, say [3, 7], we can set the entry to true by

board[3][7] = true;

We now have the panels stored - but how do we find a route for the player to move from one panel to another? We have to use a search algorithm, exciting stuff.
Have a read through this article: Pathfinding - Wikipedia
For the sake of simplicity, I’d try implementing Dijkstra’s algorithm where the edge length between each panel is just 1. If you need some more help give me a shout!

Ooof like I said before,

I have no idea how algorithms work sadly :frowning:

Was hoping for another way to somehow do this but if thats the only case then I would need you to elaborate a lot more on how to use it.

Have you read the wiki page?

I can understand if it is very overwhelming! You haven’t given us any code that you’ve written though, if you have no idea where to start you may want to do a smaller, simpler project first!

Currently, for coding wise, all I have is something to prevent the players from moving:

local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild(“PlayerModule”))

local Controls = PlayerModule:GetControls()

Controls:Disable()

other than that I have nothing for the board’s movement, I have coins all coded but I don’t think you would need that script

Is there any tutorials that could possibly help out if I decide to give algorithms a test?

EDIT: Or better yet, would there be a way to raycast or find the region of the player and the nearest panel then use the :MoveToFinished function every time the player moves to the neighbouring panel?

1 Like