Restrictive Click to Move on a Grid

0 favourites
  • 6 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • So I've been doing a bit of the tutorials to get familiar with Construct 2, which is a really awesome tool - loving it.

    What I'm trying to accomplish is moving a player about a hexagon grid by using the mouse as a click-to-move feature. I've got that part actually working, however, the player can move themselves freely about the map. There isn't any pathfinding or limit to their distance.

    I'm trying to implement the functionality to only move to the space adjacent to the player, essentially a 1 space radius around the player.

    This is a bit more confusing than I thought and it was hard to search the forums for this - I found mouse movement, but it was just point-to-point and I found grid movement, but that was using WASD or other keys.

    So, the main problem is only allowing the mouse click to move the player onto an adjacent hex tile only. I went about it a few different ways and it seemed UID's were the way to go, although this got just as confusing. I think I need to use instance variables too?

    dropbox.com/s/nkd170m1q9l261s/1_HexGrid_MouseClickMoving.capx

    The capx should have everything in it (I made it a project, but everything should be in the layout - chess, tile - that's about it.)

    Also, I was fudging it a bit just now and saw something weird where it spawns one at where it should, but then when it moves, there is another one. Not sure how that came about since I got rid of all the stuff I was trying to do, and put it back to how it was.

  • Alright, so maybe I wasn't clear in what I'm trying to. Got a lot of views, but no replies.

    If you can, think Heroes of Might and Magic 2, where in a battle your troops move via hex grid. They have a limit to their movement, like the Skeleton or Peasant. So then bake that down to moving them one space at a time and that's what I'm trying to make.

    I'm trying to make it so that you can only move a player piece to a neighboring grid cell using the mouse.

    I tried accessing getting the UID of the player piece, so that way I can determine where it can move to. However, I was hoping there was some kind of "check for neighbors" function, because I can't figure a way to get it's neighboring tile's XY.

    Is this too advanced for someone starting out with Construct 2? I can see most tutorials are for realtime movement with very few talking about turned based on a grid type movement.

  • It seems that no one has a clue, even after so many years...Sad...It would be great if someone figures out how to make a Heroes of Might and Magic system.

  • RODInteractive

    This can be done fairly easy, but it depends on how you build you grid.

    Have you seen the FAQ? There are a few examples of grid movement:

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey RODInteractive!

    This page has a very detailed description on how to use and implement hexagonal grids:

    https://www.redblobgames.com/grids/hexagons/

    It's not focused on construct, but you can do everything there with it. If you need any further help with your first tries, just let us know.

    Hope this helps. Cheers!

  • Thanks brunopalermo , sorry for late response, I've been busy with other projects

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)