Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Tile Based Map Nav

Discussion in 'Assets and Asset Store' started by Leslie-Young, Jun 2, 2012.

  1. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Last edited: Jan 17, 2015
  2. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799
    Nice - just watched the video, looks pretty straightforward and useful. Does your package work with non-flat maps as well?
     
  3. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    [edit] Yes, since version 2.1
     
    Last edited: Jul 13, 2012
  4. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
  5. johny

    johny

    Joined:
    Aug 31, 2011
    Posts:
    133
    Is there a pre-built basic attack function where they units attack each other?
     
  6. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Yes, there is a sample of how to have one unit attack another. I totally forgot to show it in a vid, but touched on the attack markers in video 2. It is very basic attacking though and units do not even take damage or get destroyed. I feel it is something that will have to be changed depending on how your game works so I've given just enough to get started and see how you can create your own units from the base unit type.
     
    Last edited: Jun 8, 2012
  7. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    I've updated the package to version 2.1

    This release includes the requested variable height tile nodes feature and new options for how units move around, including jumping units :p
     
    Last edited: Mar 29, 2014
  8. johny

    johny

    Joined:
    Aug 31, 2011
    Posts:
    133
    Another question. How hard would it be to implement a system where you make your turns then every move made plays out at once?

    EDIT : also would the new height system work with normal unity terrain? Also did you make battlemass or is that just some one who used your system?
     
    Last edited: Jun 8, 2012
  9. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    is it possible to have the attack marker only show on valid attack target ?
     
  10. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799
    Wow, that was pretty fast. :) Instant purchase now!
     
  11. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,044
    It looks very nice and polished, but I have one thing that I consider a major issue: You use one quad per node, which ends up being 4 vertices. If I would like to create a really big, big grid - this would not scale at all. If I wanted a 512x512 grid, I would end up with using 1048576 vertices just for the grid. Which would slow a lot of machines down to a crawl.

    Edit: just watched the 2.1 update video with the variable height, Looks very nice! But the way the "move" marker clips into the terrain looks very cheap/bad and I would expect it to flow with the terrain.

    Overall, it looks very good - but some of the display issues worry me, which is why I'm not buying it yet!
     
    Last edited: Jun 8, 2012
  12. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    I don't think that would be too hard to implement, for moves at least. You could use the current unit class as a template and then replace the movement code with something that calculates the path, set the destination node as occupied and then save off the path info till it can be used to move. If Units, moving through each other, is not a problem then it could be done; and even if it would be a problem I there would still be ways around it, but this is not a feature outa the box where you just set a boo lto true and you have this feature, it will involve some code from your part. The current turn sample is just that, a sample, and not seen as the core of this package, which is the mapping, grid layouts and some base classes for things like units to calculate paths for example.

    Battlemass is a game I've developed and was the inspiration for this package.
    I've not yet tested with Unity Terain, I'll look into that.


    Those markers are not all on at the same time. The idea is to use them to indicate where units may move and you do not even have to use them. It is just an easy way of showing them. That said, this package is best for situations where you would have a grid of say 50x50 or smaller, like in Battlemass, or one of those games where you switch into a turn based strategy map for combat, as examples. It can become quite hard to use in the editor if the grid is something huge, like 100x100+, and you do not have a very powerfull machine.

    Concerning the terrain, yup, it does not look cool in that sample and I am gonna add more samples of how one could use other methods like projectors rather than the flat markers.
     
    Last edited: Jun 8, 2012
  13. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,044
    Ok, I think I will have to re-consider my thoughts on purchasing this then, It looks really solid, but I'm looking at 2048x2048 terrains in my current game. I've been working on basically the same thing you have, but with a larger scale in mind and have managed to come up with a way of visualizing basically infinitely large grids, with support for things like unit sizes, dynamic updates of the grid, etc. currently only does colored squares, but working on hexagonal visualization and using symbols instead of colors for squares, example:



    The grid in the picture is 1024x1024. Anyway, great work and I will not try to hijack your thread, keep up the great work!

    Edit: Also, I realize the visualization for the "movement" marker is very fast to render, but what I was more concerned with was the actual visualization of the grid inside the editor, when you can see the whole grid and you're both using the hexagons + cubes, which will crush any standard machine if you try to display a 1024x1024 grid, that requires a quad for the hexagon/square and then a cube to display the other data, that is 12 vertices per node, which at a 1k grid ends up being ~12 million vertices.
     
    Last edited: Jun 8, 2012
  14. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    @Johny
    I did a quick Unity Terrain test and the Height Setup tool works with it and the units bascially move in the same manner as they do in that 1st sample shown in the 2.1 video. The default grid is small compared to the size of the default terrain though, if you do not change the tile size and spacing from 1. Let me put it this way, a 20x20 grid needs tiles of size 100 (spaced 100 from each other) to almost fill the default terrain, but I guess it all depends on what you need it for.



     
    Last edited: Jun 9, 2012
  15. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    I've updated the package to v2.2.

    This update includes a sample of how the package can be used with a dungeon crawler and a new way of telling the path calculator that units ned to spend more movement points when trying to enter certain tiles.
     
    Last edited: Mar 29, 2014
  16. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799
    Would it be possible to add an option to block access to a tile from certain directions? Or are the connections between tiles all fixed? I don't want to jump my units up on a very high cliff (or back down for that matter) but access should be possible if you take the long way around.
     
  17. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Interresting idea. I'll have to look into how I can add a way to break connections since they are recreated each time at runtime.
     
  18. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799
    Maybe you could use this for a door mechanism in the above dungeon crawler scenario as well? Ah, the possibilities... :)
     
  19. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Update 2.3 includes the ability to switch the links between nodes to on or off. Usefull for doors, or preventing movement from certain tiles to their neighbouring tiles, thanks for the idea, c-Row ;)



     
  20. lucked

    lucked

    Joined:
    Jul 11, 2010
    Posts:
    111
    any Web Player Demo? please
     
  21. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Rather check the videos I've linked in the 1st post. This package is more about the code and editor features than any one sample, so the vids will give you a better idea of how it is used.
     
  22. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    Just check for v2.3, there is a warning.

    Assets/Tile Based Map and Nav/Scripts/TMN/TileNode.cs(58,58): Warning CS0665: Assignment in conditional expression is always constant. Did you mean to use `==' instead ? (CS0665) (Assembly-CSharp)
     
  23. cannonball1978

    cannonball1978

    Joined:
    Jun 12, 2012
    Posts:
    1
    I'm working on a game that could use a couple of things:

    Multiple units or sprites on one hex tile to indicate tile statuses or obstacles or the like.

    Randomized hex heights or board limits perhaps based on a procedural grayscale shader? Then the ability to plot hex prefabs to those hexes (generating terrain from randomized array).

    Maybe a unit creator?

    If I had that I'd plonk down some dough.
     
  24. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799
    Just out of curiosity - how is movement handled? Do you generate an array of waypoints once the movement command has been given?
     
  25. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    oh my. .thanks. I'll fix that for the next update. Just hot patch it on your side.
    Everyone else, line 302 in TileNode.cs should read.
    Code (csharp):
    1. if (ls.neighbour.linkOnOffSwitch != null)
    Strange that VS is not bugging me about it when I hit F6 to do a test build.
     
    Last edited: Jun 12, 2012
  26. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    MapNav.GetPath(...) generates an array of TileNodes. It does not however take into acocunt how far the unit is allowed to move, so you could ask it to get a path from where the unit is now up to some random node, usefull for AI that wants to reach some destination over time. NavUnit.MoveTo(...) shows how I take this array and then make sure to only move the unit up to the number of nodes it was allowed to actually mode. In the demos the MapNav.GetPath won't return an array with more nodes than the unit may move seeing as the player can only click on visible nodes that are in movement range, but I've added the tests in NavUnit.MoveTo for just-in-case and as sample.
     
  27. RichBosworth

    RichBosworth

    Joined:
    May 26, 2009
    Posts:
    325
    Hello,

    I sent you a PM regarding the use of this product in a specific scenario. I just wanted to check if you had received it or not.

    Thanks,
    Rich
     
  28. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Soz, I had the PM notifications off and totally missed it. Turned 'em on now ;)
     
  29. SeanP

    SeanP

    Joined:
    Feb 27, 2011
    Posts:
    38
    How hard would it be to add a check for neighboring nav maps, and then link them? either in editor, or during runtime. Both would be preferable.

    Also I just purchased this, is a very nice package.

    I would also like a way for the 8 square grid, to disallow diagonal movement, if there is an obstruction, my example would be this image where the corners of the doorways are blocking the path.

     
    Last edited: Jun 12, 2012
  30. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    There are inconsistent line endings in the 'Assets/Tile Based Map and Nav/Scripts/Sample/SampleDungeonDoor.cs' script. Some are Mac OS X (UNIX) and some are Windows.
    This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.
     
  31. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    Now, each TileNode can contain 3 Units, how to only limit to one unit ?
     
  32. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Units are set to move on certain tile types. In the samples I have air, land and water. All tiles that incl "air+land" in their masks will thus allow those type of units to move onto them. If you want only one kinda of unit to move on certain tiles, then just set them as such. For example, modify the tile type mask for a tile to only allow land and only land units will be able to move over them.
     
  33. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Check this post.
    I've added a switch type thing for nodes, to break links (v2.3). Simply select the two nodes and click on the "Off" button to break the link. The sample shows it with a door, but that is just to give you an idea of how you can turn these links on again during runtime if you wanted.
     
  34. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799
    I think what yuewah is trying to achieve is that a tile should be able to contain both land or air units, but not both at the same time. Not sure if this is the standard behaviour anyway, though - in the Scene 1 example, I never tried to move an air unit on the same tile as a ground unit but immediately opened fire instead.
     
    Last edited: Jun 13, 2012
  35. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    You can move the Land unit under an Air unit with the same color.
    I just modified a bit for my need as I want the game to be much more simple, having three units in a single tile seems too complicated.
     
    Last edited: Jun 13, 2012
  36. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    I'll add this as an option for the next update.
    It is simple enough to put all Units on the same tile type layer, but I can see situations where you still want only flying units to move over certain tiles, but also don't want them to be able to move over tiles occupied by land units. This is easy enough to implement, but I can just as well add it as an option that is build into the core system.
     
  37. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799


    Soon.... :D

    Or maybe...

     
    Last edited: Jun 13, 2012
    TokyoDan likes this.
  38. SeanP

    SeanP

    Joined:
    Feb 27, 2011
    Posts:
    38
    Does this work between two separate MapNavs? or does it have to be the same, I would like it to work between separate ones.
     
    Last edited: Jun 13, 2012
  39. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Links between maps are not supported atm. What do you need to do that can't be pulled of with one?
     
  40. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Update 2.4
    Added the options to set if more than one unit may occupy a tile. Small bug fixes. Some changes to the movement code to allow units to move at the same time and wait if another unit is in the way. Added option to GameController to turn auto-random movement of units on.

     
  41. SeanP

    SeanP

    Joined:
    Feb 27, 2011
    Posts:
    38
    I want to be able to place tiles at run time that have gids on them, and link together automatically. I know you could do it the way you have it in your dungeon maker, but that requires the full grid to already be generated, and is limited in size.

    If they can connect dynamically, then there are less total grids to be calculated and should allow for larger maps.
     
    Last edited: Jun 14, 2012
  42. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    The TNEMovementModifier is a good start, but it is too simple. It now only support for TileType, can it support more, e.g. Unit Type etc.

    I have modified by passing the starting node to support more checking.
    Code (csharp):
    1. this._ShowNeighboursRecursive(radius, true, validNodesLayer, checkMoveMod, checkOnOffSwitch, this);
     
  43. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799
    Moving platforms or elevators for multi-level maps where the elevator's mapnav is linked to the current floor, although I guess you could find a workaround for this, like two mapnavs overlapping at one point. You could then assign a unit to the other mapnav's tile by hand. Not exactly the most elegant solution, though. ;)
     
  44. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,036
    Cool... Battle Isle and Incubation... I worked on the latter one ;)

    Planning on doing a fan game or considering the same settings?


    Back to topic:

    - Is it possible to set something like "height offset" to filter hex tiles that are too far off their neighbors height? I've implemented such a thing for one of my game prototypes.

    - Does this script have any kind of "API" ? i.e. is the grid generation code separate from the editor code? This would enable me to call the generation code in run time (for generated levels)...
     
  45. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    Not sure what you mean by the first, or rather where you want this to be done? Like maybe in the editor toos when you want the tool to do an auto setup of links that units could move to?

    To the second, yes, there is what I guess you can call an API. The tile creation and linking and all that has been seperated into the runtime classes and the editor scripts make calls into them. So you can have maps creation happening at runtime for example.
     
  46. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,053
    So you guys inspired me to try this idea of having more than one MapNav and link the nodes between them. Is a manual job where you have to select the two nodes and click on "Create Link", but it seems to work. I'm gonna play around with it a bit more for the next update.

     

    Attached Files:

    Last edited: Jun 15, 2012
  47. SeanP

    SeanP

    Joined:
    Feb 27, 2011
    Posts:
    38
    This is amazing! If you can make it so these links can be detected/set through code it would be so useful! and would make the game im prototyping a total possibility!
     
  48. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    Does you package work with Indie?
     
  49. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    799
    Basically this but with some kind of automation, depending on height differences.


    Ha! You deserve some envy here. :)

    "Drawing some heavy inspiration" I would say. xyber's asset just screams for something like those two. They were already on my never-ending to-do list anyway, and with every update he releases, they move further up that list. Wish I didn't have so many unfinished projects already... :D
     
  50. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,008
    Do any of you guys know any tips for coding enemy AI with this excellent tool , I'm such a noob I have no idea where to even start!
     
unityunity