News Forums RAIN Sample Projects, How To, and Code Automatic hex grid - scripting the automatic waypoint creation

Tagged: , ,

This topic contains 2 replies, has 2 voices, and was last updated by  McRoastbeef 3 weeks, 2 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #39009

    McRoastbeef
    Participant

    I’m making a hex grid, in which every hex is a separate mesh. The hexes have pivot set at the center of their top, so transform.position returns the coordinates of hex top, not inside the mesh. Hexes are going to be prefabs. Hex radius is 0.5 meter and pointy ends lay along the Z axis.

    The first thing is I’d like the code to work in the Scene view, not only in Game mode. The script needs to do the following:
    1. The hex is snapped to the grid in X and Z axis, in Y axis it can be moved only by 0.1 meter.
    2. The first hex is automatically placed at 0,0,0.
    3. Placing a hex automatically creates a Waypoint at its pivot point.
    4. After placing a Waypoint the script checks whether there are any neighbours and connects to them if they exist.

    I spent 2 days trying to code that but something is wrong all the time, I think posting my code(s) is purposeless.

    • This topic was modified 1 month, 1 week ago by  McRoastbeef.
    #39021

    Sigil
    Keymaster

    Well… have you gotten your hex generation working? The part that puts your prefabs out and lines them up appropriately.

    In addition to that placement, you’d also need to make sure that you inform each hex of its neighbors as you place it, that way when you come back around to create your waypoints you will already know where your neighbors are.

    I can help you work through some of the details with a little pseudo code if need be, just need to know what you have.

    #39098

    McRoastbeef
    Participant

    I managed to get the thing to work but with my maps the amount of hexes causes massive lag. Different solution is needed.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.