HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Hex grid  (Read 1055 times)

angelsin

  • World Owners
  • ****
  • Posts: 33
    • View Profile
[Resolved] Hex grid
« on: Jul 22, 12, 09:38:45 PM »

So I am new to this, and I was wondering if there is a way to setup an invisible grid system, for things like attack area and range, and if this is possible, if it could be changed from a square grid into a hex grid or if that would likely be too much trouble? I have been planning on working on trying to figure it out but thought I would ask first to see if someone else knew of a simple way or if others had tried and found it to not be worth it.
Thanks in advance
-sin
« Last Edit: Nov 01, 12, 03:00:24 PM by HE-Cooper »
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Hex grid
« Reply #1 on: Jul 22, 12, 10:23:56 PM »

Are you planning on having these hexes be discrete positions where the units can be (digital), or can they move freely to any point on the map (analog)?

We are using a hex grid and it was quite a bit of work to get going, but with satisfying results.  We use discrete positions.  The key aspects were getting the grid laid out programmatically, and creating a path finding system which plans along the hexes.
« Last Edit: Jul 22, 12, 10:30:51 PM by ScottZarnke »
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

angelsin

  • World Owners
  • ****
  • Posts: 33
    • View Profile
Re: Hex grid
« Reply #2 on: Jul 22, 12, 10:56:00 PM »

I was thinking it would appear to the player as fully free motion, but would in reality be discrete positions, which is part of why i wanted it to be hexes. I was thinking of it in table top battletech kind of terms. I felt it would make the style of combat I am planning easier in the long run if the players were in designated spots, so that techniques could be resolved by area rather than by single target. (eg player 1 hits all targets in three adjacent hexes in front of them)
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Hex grid
« Reply #3 on: Jul 23, 12, 12:07:50 AM »

Yeah, definitely doable.  You'll want to plan a way to take the grid pattern that designers come up with and have the scripts calculate the positions relative to a given starting point (or else you'd have to manually mark the positions, perhaps with path nodes, but that can be tough for a large number).  You'll also need to store those positions in a node graph.  Then, the most commonly used path finding for something like this is A*, which is what we use with straight-line distance as the heuristic.

Range between two given hexes is done by finding the path between them and then taking the length of that path.  To find all hexes in given range of one hex, you can do a breadth-first search from the center.  Each generation down from the root is one more unit away, so a range of 3 would search to a depth of 3 and keep track of each tile found along the way.
« Last Edit: Jul 23, 12, 12:20:53 AM by ScottZarnke »
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

angelsin

  • World Owners
  • ****
  • Posts: 33
    • View Profile
Re: Hex grid
« Reply #4 on: Jul 23, 12, 03:16:16 AM »

Thank you, that definitely gives me a good hopping off point.
-Sin
Logged