Simple Hex-Based Game Design for Unity 3d – Episode 1 [Livestreamed]

38
6



I get a lot of questions about the basics of setting up a Hex-Based Tile Game. This is from the Patreon-funded livestream for January, where I try to address these questions.

Topics: Map coordinates, mouse interaction, 3d tiles, and some pathfinding concepts.

Make sure to SUBSCRIBE so you don’t miss a video!
Download the complete project:
Also, please feel free to ask lots of questions in the comments.

This channel is mostly all about game programming tutorials, specifically with Unity 3d. You may also be interested in my primary channel, where I play and review games:

I can be reached at:
quill18@quill18.com

Nguồn: https://fivestarhotelsantalya.com/

Xem thêm bài viết khác: https://fivestarhotelsantalya.com/game/

38 COMMENTS

  1. first: thanks for the tutorials.
    second: you forgot to mention that the code has to be sent manually with a click the first time you want to add GameObject hexPrefab

    third:
    Instantiate(hexPrefab, new Vector3(x, 0, y * zOffset)

    i am talking about bloody conventions. you start the map with the convention x,y, z.
    i do NOT care if you name them
    a,b,c.
    or
    q, e, d.
    but it is IMPORTANT practice that once you START a convention, you use it to the bitter end.
    you do NOT use as a, b, c, then use for some variables b when you add to a, to other variables c when you add to b.
    it will fuck you up really bad in the long run.
    yes, you can see the problem when you have 20 lines of code. but when you get in the 1.000's you are screwed

    keep up the good work 🙂

  2. @quill18creates i'm sorry but the system you're suggesting is easily the worst implementation of an hex grid. I suggest you give a look at this: https://www.redblobgames.com/grids/hexagons/

  3. Why game designers use y as z has forever blown my mind, you just create an issue. Simply allow Z to be through the screen then everything lines up.

    But NO for some reason, your mathematics has to have z in the vertical of the viewport plane.

    Axis is supposed to follow the coordinate offset of the natural viewport.

  4. 18 minutes after ypu do something, i think you speak to much , but too much word made confusion, there is not a clear path

  5. I just wanted to learn how to code hex based tile to see if I can build a map builder but then you like turn out to play other games including the only game I play in the only mode I play in. Such a coincidence.

    I don't want to seem rude but we are getting older and we should move in together, get married, and have children soon. Is next week good for you?

  6. why is creating multiple hexes fine, while multiple squares isn't?
    could you make a plane whose mesh is made up of hexes, to be more efficient?

  7. I got the Math for a 2D Hexfield:
    My sprite got a height and width of 1 Unit while its a perfect Hexagon with a rotation like Quills here (height > width).

    //int tile.X, tile.Y are the positions of a tile in the array;
    float worldPos_x= tile.X * Mathf.Sqrt(3)/2 + (tile.Y % 2 == 1? Mathf.Sqrt(3)/4: 0);
    float worldPos_y= tile.Y * (3f/4f);

    I hope this helps you out!

  8. North South-ness, east west-ness, that completly worked for me. I could think of a better way to describe it, i will be using that often

  9. To get no gaps between the tiles you can use the following offset if the height of your tiles is 1:
    float xOffset = Mathf.Sqrt(3) /2;
    float zOffset = 0.75f;

  10. Man, I wish I had known to do that XYZ gameobject parenting thing some time back. Quill didn't lie, that shit ended up being a LOT of trouble

  11. First I thought "Uh, wat an interesting topic for an Unity video", but then I saw it's narrated by that annoying guy…Skip 😉

  12. To make 3D model to be correctly imported from blender to Unity artist can rotate the model by -90 degrees on X axis, bake rotation and then rotate is by 90 degrees on X axis. With this Unity will import the model with 0,0,0 rotation wich I found much more easy to work with then using the parent object technique.
    Also when exporting in blender to fbx you can set forward as Z forward and toggle that little button next to scale. This will make Unity preserve the correct scale when importing the model without messing with import settings.

  13. I'm going to be buying a laptop computer soon I have an under $ 1,000 budget and I was looking for some advise or recommendations.
    I want to run blender or Maya and some Auto Card, and I want to learn to program python.

  14. +quill18creates Hey Quill i know you were eyeballing the coordinates but… here is a small helper function to calculate the exact coordinates for a given hex diameter with a required padding. this assumes the hex tile is taller than it is wide.

    // note Padding is a public class variable
    // diameter is the length of the longest line you can draw from point to point.

    Vector3 calculatePos(int x, int y, float diameter) {
    float d = diameter + Padding;
    float alpha = d / 4;
    float beta = alpha * sqrt3;
    float posY = (d / 2 + alpha) * y;
    float posX = beta * 2 * x;
    if (y % 2 != 0) {
    posX -= beta;
    }
    return new Vector3(posX, 0f, posY);
    }

  15. Hey, Quill, do you know anywhere that i could get direct help with scripting and artwork for a tactical unity based game? If you could tell me anywhere that i could get this for free or quite cheap, i would be forever grateful.

  16. I much prefer cube/axial co-ordinates for hex-based games.  It's somewhat less neat to setup and store the grid than the offset system, but the co-ordinates make more sense and a lot of algorithms are made simpler.

  17. A bonus question/feature if you will. Know how a boardgame like Catan uses the space in between hexagons for other objects. Could you show an example of using all of the vertices as a separate grid?

  18. Hello! i've got a problem with Character Controller… how to launch CC in the air like on jump pad but diagonally (verticaly and horizontaly in same time) like in UT or other games. I can only super jump(only verticaly). Any piece of advice ? And sorry for my english… not my mother language .

  19. Next up: 3D rhombic-dodecahedron-based tiles! 😀
    (You really could have included the maybe one more minute required to at least complete that initial tiling within this video)

  20. Look at that… just when I'm writing my own little experimental implementation for a first prototype of a tactical game, this pops into my mailbox.
    Fantastic. Thank you, a lot!

LEAVE A REPLY

Please enter your comment!
Please enter your name here