• News

• Industries

• Learning & Support

• Community

• Marketplace

# Calculate and highlight player`s movement end point

Hi there everyone!
Im working on one project, its a table card game and im stuck with one issue, so rly could use your help here :\
Red dot - is a player, Yellow - is a blocking volume, Green - is a movement route, Green cross - end point.
So the game tells to player that he has enough action points to reach that square (market with green cross, or any other actually depending on how much AP he earned, but he cant stop in the middle of his way). To cross every square player has to spend 1AP.
As for movement - im using navmesh with AI controller and player should click that square to start moving to it. But i dont want that player would have to count squares each time when its his turn to move.
Thats why i want an engine to do this for him and highlight that sqare as end point, but i totally have no idea where to dig.

So would be highy appreciated for any advice!
P.S. was googling for someking of tutorial on this and failed

I would probably start out by making your floor tiles into blueprints, or having them be components of a blueprint that stores their indices in order. They could still be regular meshes and you just add them to another BP array in the right order perhaps.

Then if you store the current tile index for any character you can easily find the destination tile by doing current index + AP and retrieving whatever tile has that index.

Hey RyanB! Thx for your idea!
Actually thats exacly what i did, all my tiles are separate BP`s, cuz everyone of them is launchin a custom event, when a played stops on it. The thing which i totally cant get in my mind is how to show a player which tile he is able to reach, according with his current AP`s…
The problem is that my drawing is just a simple example, but on the game map player can go left, or up, or right so im not sure how to make it with index…

Maybe this image will clarify what I am trying to suggest. The green tile would be the starting tile in this example, with index 0 and length along path of 1 (or could be 0 as well but I made it 1 here).

You could store 2 arrays that are kept in alignment by always adding to them at the same time. First is the array of Tile Blueprint references. The second is an integer array for storing each Tile BPs ‘distance’ along path. It will be beneficial to have this all stored in one place on some kind of gameplay or board manager blueprint so you don’t have to go querying all the BPs.

When you are first building your game board, as you add the tile BPs into the world, add references to them to the first array. Then you add the length along the path as an int to the second array. That value is the black text in the above image. Note that all tiles after a fork in the road get shared values since they are all the same distance. Ie there are three 4’s in the above image. The blue text would be the unique index of each tile that would actually be used to retrieve the tiles BP references from the 1st array to tell it to Glow or something, or to make it clickable perhaps by sending an activation event.

For example if we wrote out 2 arrays for the above image it would look like this:

(left is the unique index or blue text, right is the black text or the ‘distance’ along path)

0 : 1
1 : 2
2 : 3
3 : 4
4 : 5
5 : 4
6 : 5
7 : 4

You may need to store a ‘stack’ of current distances whenever you start a branch and then ‘pop’ the value whenever a branch ends and you need to continue down the parent path. If you are not familiar with using a stack to push and pop from the list, do some basic reading on those. They are fairly universal concepts and quite important to problems like this where you are trying to parse something in a specific format.

I see your point RyanB. I was thinking about the same system for some time, it will work, i actually created it in c++. It is a matrix of some sort of all tiles in the game where a player can go. The only one thing i dont like in this method is that its actually hardcoded, you need to code those 2 numbers for every tile in a game and if you will change the tiles alignment you gonna need to change a lot in this matrix. I wanted something more dynamic, what is not wired so hard to a tiles position in the world against eachother. So i made a complex blueprint system with multiple tracing mechanics, testing it a.t.m., seems o be working!
But thank you RyanB for your ideas, they help a lot! ^^

Yes I see what you mean.

If you want to parse it in realtime with changing tiles, you could try building it more like a linked list. Inserting something into the chain should be simpler since you just need to add references, things don’t need to be re-ordered every time.

If you give your tile BP a variable that is an array of children, you could continually just delve into the children until the number of points is gone. Then however many active tiles are returned will be the number of possible moves.

Can someone explain me, how is thatworks
you can click on any passive and it would find the way from closest point