Announcement

Collapse
No announcement yet.

Calculate and highlight player`s movement end point

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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

    Click image for larger version

Name:	Безымянный.jpg
Views:	1
Size:	29.9 KB
ID:	1169295

    #2
    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.
    Ryan Brucks
    Principal Technical Artist, Epic Games

    Comment


      #3
      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...

      Comment


        #4
        Click image for larger version

Name:	tiles.jpg
Views:	1
Size:	17.2 KB
ID:	1097729

        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.
        Last edited by RyanB; 12-29-2015, 03:26 PM.
        Ryan Brucks
        Principal Technical Artist, Epic Games

        Comment


          #5
          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! ^^
          Last edited by Cobas; 12-31-2015, 02:38 AM.

          Comment


            #6
            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.
            Ryan Brucks
            Principal Technical Artist, Epic Games

            Comment


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

              Comment

              Working...
              X