How do I create a grid-based range indicator?

0 favourites
  • 9 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Got my movement system up, grid based moving etc.

    But how do I display a range indicator that is based on square tiles?

    Example:

    I thought about using an original range sprite, creating multiples of it via events, repositioning them and pin them to the player. But then again C2 doesn't seems to let you have control over objects created via an event...

    Any thoughts?

    I wanna do an Fire Emblem/Advance Wars clone.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I made this a while ago:

    I'm unsure if it would be helpful, it comes across as fairly complicated.

    Basically what you could do first is place all your tiles down as sprites. Next put the tile sprite in a family and give them a boolean variable called "selected". The reason for a family is so two separate instances can be referenced.

    You then can expand the selection one unit in all directions with:

    Family1: boolean "selected" is true

    Sprite: is overlapping family1

    --- sprite: set selected to true

    Throw a repeat above that if you want it done multiple times:

    repeat 2 times

    Family1: boolean "selected" is true

    Sprite: is overlapping family1

    --- sprite: set selected to true

    The only issue now is diagonal tiles are also selected. To fix that make the tile's collision polygon with beveled corners or more octagon shaped.

  • Well, thank you, but it seems like I have to search for another way to get this going...

  • Well... hmm, you could just create the highlighted squares around the center one with a bunch of create actions. But I consider that a brute force way and I'm very lazy when it comes to repetitive stuff like that.

    On a side note you certainly can control objects you created with events. There just are a few picking things you need to consider.

    For instance:

  • I use distance as a radius range:

    https://dl.dropboxusercontent.com/u/659 ... ient3.capx

    The example also show how blocking path works.

  • I've the same question but I also want to include movement cost in the range display.

  • kbad10,

    You can learn and modify the interactive dragging pathfinding: https://www.dropbox.com/s/0qvn9i8v2m2riyy/pathfind_drag.capx?dl=0

  • alextro thanks for the Capx. Is it possible for you to provide some explanation for the code? I'm really trying to understand what is happening but can't seem to understand. Also, it seems that in this code each tile(nod) has a cost of 1. However, in my project, the cost is different for different tiles.

  • Actually my example is just showing how tracing step works, it doesn't calculate terrain/tile type cost.Try searching on forum about it cause someone else already discover the topic.

    Here an example like previous one but with moving object with simple clicking:

    Here alternate way (no tilemap, no plugins) to do that:

    https://www.dropbox.com/s/ibrle5bdb4rhm ... .capx?dl=1

    Actually the example derived from previous topic: flood-fill-and-path-finding_t170394?start=10

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