How to create Ludo Game

I am up to creating 2D ludo game , where the coin follows the path and make moves based on the dice number, how to make the way points for the coin movement instead manually feeding , is there anyway of automatically giving instructions to the coin, so it can follow its path


The coin/token could be responsible for its own movement, if it has (say) a Move(int tiles) method on it that can be fed the dice roll each time: Move(1), Move(4), Move(6), Move(2), etc.

The coin would then want to animate its movement to each subsequent tile; and so you probably want to represent the board of tiles in memory somehow (or just reference their game objects) and have each tile able to say which the next one is going to be.

Then the coin queries its current tile and says “hey, which one is next?”, gets the result, then queries the next tile to say “where are you?”, and then animates towards it. Repeat for the number of tiles it has to move.

Something like that would let you handle the situation somewhat generically, at least until you get to any exception circumstances. For example, I forget the rules of the game exactly, but I believe there’s a branch off one of the tiles to go up to the “end zone” for a coin, but you’re only allowed to enter it if rolling a specific number like 6 or something? The Move() code for the coin would then need to take that into account when querying the current tile for its properties and determining if it’s the right type to make these conditional decisions or moves.

But you can figure that out and add it in once you get the basic board movement sorted out.

The good thing about creating a somewhat generic movement pattern like this, is you could create some custom crazy ludo board designs, and so long as the chain of tiles around the board can still figure out where it is placed, and where the next one around it is, the game code could automatically adapt to it - maybe a future advancement to consider once you’re happy with the base game.

1 Like

Thanks for answering
but is there anyway of automating the Tile details like the current position and next position without manually feeding the tile with the next tile in script
example :
lets say every tile has script which has next tile (but its manually feed ) is there anyway of automatically feeding the tile with its next tile
if you look at this tutorial , here the chess pieces are not manually feed with gameobjects

I want to make the tile information automatic


I would say yes there is, but I would also say, is the effort to do so going to be worth it?

What’s your end game (rhetorical question). The features you plan to support will help determine what data structures you’ll need to create and reference.

If it’s just to ship with a single regular ludo board design, then it’d be quicker to punch in the details into exposed (serialized) fields of the inspector of a bunch of game objects that make up the tiles, than it would to create some way of automatically deriving them. Doing it manually may take all of 5 minutes to do, however tedious it might be to punch in the values on each tile.

If however you want tiles to be able to discover for themselves who their adjacent tiles were, you could script that in too.

How you do that is up to you - raycast down from the sky to the tile positions around you, seeing if you hit another tile or not, and if so, add them to this tile’s list of known partnering squares. That would be fairly quick to do, would be flexible (in the event you have multiple board designs or even want to ship an in-game board editor), and one such way. You’d still have to figure out a way to handle that scenario where a tile has more than 1 outbound tile it can go to, and then of those which is the way to the end zone and which is part of the outer loop, but it’s a small detail.

Then if each tile knows its adjacent possibilities, and if the coin knows both the tile it is on and the last tile it came from, it should be able to fairly easily ask that tile which other directions it can go in from here.

1 Like

This is a greatest reply that I could get from and this

can you explain a little bit , raycast from sky means , how to do that?
thanks for answering

From any tile you are on, there are I guess 4 other potential tile positions you could move to (or have moved from), always at a fixed size or offset. I am assuming diagonal moves are not possible on this board.

Doing a raycast on each of those positions somewhere “above” the board looking down (although it might be a 2D board or game, you can still do this in 3D space), the raycast hits should be able to reveal if there was a tile there or not.

So the point you cast from would be directly above each of the tile positions, and in the direction down towards the board (which might be “down” or “forward” depending on the orientation of the board in the scene). It will go some distance before hitting something or giving up, which is why you want to start a bit away from it.

So then you’ll have a general answer no matter the design of the board or the current location of the coin, without having to hand code in each one.

Whether you do that dynamically on each turn and move from tile to tile, or scan the board once at start and then record the results inside each tile, is up to you. For a game of Ludo the performance hit of doing a few raycasts per tile move is probably negligible to not worry about it.

The real issue is how classic or fancy you plan to make your game. Doing it dynamically per move opens up the potential scope a lot, including for example a board that changes its layout during play. However if you have no intention of doing that and just want to go classic, no need to bother with things like that.

Sorry I can’t be more specific at this overall view of the problem. Without having to go to the lengths of an actual path finding algorithm such as the one covered in the tower defense section of the course, there are a few places that cover the tools you’ll need to figure this out. Maybe have a go at it so that if you get stuck on something (or something doesn’t work) a bit more specific, a more focused answer can be provided. Lots of if’s and but’s at this high level.

1 Like

wow just great definition, which I’m searching for ,
You just explained it clearly and thanks for that
I was stuck at making the game automatic instead of manual feeding
I just need to start again but this time with more clarity thanks for that
If I got stuck at some-point I’ll be coming back to you , I hope you will be there to help me