Hi everyone!
My goal is to create a Monopoly/Mario Party style board game (single player for now) where the player moves the pawn by rolling the dice and depending on the number generated by the dice the pawn will move from square to square.
example: the dice rolls 3, then the pawn advances 3 spaces.
Creating the dice rolling system was easy, I also created the box and pawn object by giving both variables;
pawn: moves; position.
box: number.
And here’s the problem; I have no idea how to move the piece from square to square, I looked at different posts and videos and tried for 4 days straight but nothing, I don’t understand how to do it, so please, I’m asking you on my knees, can someone explain to me step by step how Do? (Better from the beginning)
I just need to know this for now.
(Thanks for the help)
There are a lot of ways to do the movement but the setup would be mostly the same. Add an object variable to the tiles or spaces like ID and number the tiles sequentially. You would then add the number on the dice to the current tile ID and then target that tile or it’s x, y. You would pick the tile by checking for a tile ID variable with that the target ID number. You would need to wrap the value around at the end since it would end somewhere and restart at 0. If you calculate the target ID with mod() that would keep the number in the range.
TargetID = mod(tile.ID +1, number of tile objects)
The movement would depend on you. You can do a simple direct tween to the new position. That would take a straight path and might look weird with corners.You could tween from 1 tile to the next using a counter variable and waiting for each tween to finish before targeting the next tile.
You could use the pathfinder. Although, it would also take the shortest path unless you also add obstacles along the edges.
You could also use the link path finding behavior. That would link the tiles and then move the player from tile to tile taking the shortest path but unlike the normal pathfinder it would stay on the tiles. There are a few examples. Instead of clicking a tile, you can get the x, y from the target tile as discussed earlier.
I’m not at my PC. So, I can’t easily create an example.
There’s an old example using the link tools in my github page. It uses a button to increase the target square instead of dice but the basic setup and method is there with comments. It’s a start for that style. Thw colored spaces do nothing. It was just for looks.
Oh all right i would definitely take a look at it, I’ll let you know tomorrow.
(By the way, if anyone else is watching this, i would really appreciate if you can share your own methods too)