Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Tile Based Map Nav

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

  1. Baconshot

    Baconshot

    Joined:
    Dec 21, 2013
    Posts:
    3
  2. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    You did not set the tile-node prefab so there is nothing to instantiate when the nodes should be created.

    Some default nodes prefabs for square and hex grids can be found under,
    \Assets\Tile Based Map and Nav\Prefabs\tile_nodes\
     
  3. Baconshot

    Baconshot

    Joined:
    Dec 21, 2013
    Posts:
    3
    Arh but of course. :) That helped. Thanks dude. :)
     
  4. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    Hi,

    I've just bought your Asset - it's certainly a very nice tool to extend and work upon.

    I am having some issues with navigation though. I created a new scene, created hexagonal 20x20 map, created layers (10,11,12 for tiles, obstacles and units), imported my custom models and copied logic from your sample one. Everything seems to be fine - there are no errors in the console. I can click on my custom unit just fine, and the available move tiles do show up (mapped obstacles are working as expected). The problem is, I cannot make my unit move. When I click on a destination tile, they disappear but nothing happens. Also, the "hover" state does not seem to work.

    My other issue or rather a question - is there any way to create a map centered on the 0,0,0 point? It seems annoying to position things by hand.

    Thanks!
     
  5. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Must be something in the script if everything else seems to work.
    Try and test your unit on the sample scene(s) first and see if it works there.

    The map will have to be moved manually as you need to position it such that is is correctly aligned over the art of your map.
     
  6. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    The same unit does work in the Sample 01.

    edit: I've just checked and dropped your units from the samples into the spawn list of my scene and exactly the same thing happens.
     
    Last edited: Jan 8, 2014
  7. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    Hey, wondering if this works with Unity 2D--i.e. - can I flip everything to work on the XY axis, or is all the code written for XZ?
     
  8. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Was developed to work on the XZ with Y for height.
     
  9. Braza

    Braza

    Joined:
    Oct 11, 2013
    Posts:
    136
    Hi,
    Sorry for being lazy to look al lthe pages to get the idea of all the features...
    I`m interested if the following is possible:
    1. Grid de/serialization
    2. Field of View and Visibility calculation? Or any means to implement it
     
  10. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    The is no serialization. The grid nodes are all actual game objects and one of the reasons that this system can't be used for too big a grid. Something like 50x50 or less.

    I suppose something could be created to disable and enable objects as they come in and out of the view but since you are not supposed to be making too big maps anyway i would not see the reason to implement this.

    If yo uare looking for something that can handle big grids then have a look at Grids by gamelogic.
     
  11. MooMoo-Games

    MooMoo-Games

    Joined:
    Jan 10, 2013
    Posts:
    10
    Hi,

    I'm interested in your Tile map plug-in.

    Can I use this hexagon tile tool for dice board game?

    I'd like to know whether there is any API to get the tile position according to a dice number.

    Thanks,
     
  12. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    The nodes are saved into an a flat array so they are indexed from 0 to the last in the grid.
    If you want the 5th one in the array you could call..

    mapnav.nodes[4]; // counting starts at 0
     
  13. seriousGeorge

    seriousGeorge

    Joined:
    Dec 17, 2013
    Posts:
    24
    Hi there,

    we're currently investigating our weapons of choice for an upcoming game. So far we considered playmaker but want to look into Tile Based Map Nav too.

    Would it be possible to teleport Units without Animation at once to the next field and/or Combine that with a rolling-dice like Setup? For example a board game where you can move according to your dice value in a certain radius.

    And also... how is playmaker Support going? Was there any Progress?
     
  14. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    From my side there is nothing being done about Playmaker support.
    It should be possible to move units around like you describe. Note that the nodes/tiles can be accessed in a 1D array. You need to calculate yourself what the destination node is when something must be moved. There is no build in feature for dice roll and auto selection of node in radius.
     
  15. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    Is there anyway to implement larger unit that larger than one tile? I tried to make horse 2 hexes in size and giant 7 hexes.
     
  16. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    The system was created with units occupying one tile in mind. I think some people attempted units that occupy more tiles before, check some of the older posts.
     
  17. bakkoto

    bakkoto

    Joined:
    Aug 5, 2012
    Posts:
    24
    Hi Leslie,

    I've a question about the TileNode.GetAllInRange() :

    what should i change-in/add-to this method to make it return only certain nodes in the returned array of nodes? like the image shown below :

    $special range.jpg
     
  18. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Not quite sure how you will do that since the pack was not really made for this.
    One thing I can think of is to find the direction to the target character and determine the angle between that and the face direction of the player character to see if it falls within a certain range, This will not help you with deciding which of the nodes are in the forward range though - as indicated by your red border.
     
  19. tomworcom

    tomworcom

    Joined:
    Dec 27, 2011
    Posts:
    50
    Hi Leslie,

    I bought your plugin and think it's really great, easy to integrate with PlayMaker custom actions too.

    I do have a question: Currently, the ability of a unit to move to a certain tile is determined by the target tiles type mask.
    When in a map with different tile heights there is a higher tile the ground unit can' t reach, the link to that tile can be cut, as shown in the tutorial videos.
    But what about air units that should be able to reach that higher ground?
    I found no way to bind the possible movement to a property on the link between tiles.
    Might that find it's way into an update or is there a way already I didn't notice?

    btw.: Is the tile system in UniRPG different from this one / more sophisticated?

    Cheers,
    Thomas
     
    Last edited: Feb 22, 2014
  20. murteas

    murteas

    Joined:
    Feb 14, 2012
    Posts:
    62
    Which playmaker custom actions are you using for this?
     
  21. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    I'll look into adding one that can handle this or modify the existing component.

    You are probably referring to my Tile Ed tool? It is simply for painting tiles, it does not handle the nodes/grid mechanics. UniRPG (plyGame) does not have any grid mechanics in it.
     
  22. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I am trying to use this asset for the first time and I am having an issue.

    If I select the MapNav the nodes disappear. I can make changes in the Inspector, but I cannot see the results.

    I have to either NOT select the MapNav (IOW select something else or nothing at all) in order to see the map.

    Here are two screenshots. One with MapNav selected and one with node0 selected.

    http://screencast.com/t/i39DY6y7Yvo
    http://screencast.com/t/A4RWIAUm
     
  23. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    In your first video around 8:40 you select a group of nodes and turn them to water nodes. When I attempt to do this with the current version I don't get that behavior.

    Screen cast at http://screencast.com/t/CTcHAOuqdoE
     
    Last edited: Feb 23, 2014
  24. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Thanks for spotting it. Seems like something changed with a Unity update. Fixed and will upload the update as soon as I had time to look at Thomas' issue too.
     
  25. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I am looking at example 6 with the projectors and I get weird behavior when I start things up. When I start things up some of the projectors are on and others are off. As I select units nothing changes. However, when I deselect a unit and click on a blank area, then all of the projectors turn off and just work when a unit is selected.

    Screencapture:
    http://screencast.com/t/rkfXVGweS
     
  26. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Version 2.9 submitted. It fixes the node gizmo rendering problem and adds a mask feature to the OnOff Link modifier so you can have it work on only specific tile types.


    There is probably a bug with the sample. if you click the terrain all the visible projectors will go away and you can test the sample as it is supposed to be - projectors coming up when you select a unit. It was just quick sample I made for someone who did not know how projectors work.
     
  27. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    @Thomas,

    Would you be willing to share your custom actions with the community. I too use Playmaker and would like to get it integrated.
     
  28. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I am curious to know if you build the map in sample03 by hand with the different hex models. I am thinking about making something similar, but I have no idea how to get everything lined up perfectly. I have seen ProGrids2 in the asset store, but it only works with squares, not hexagons. Is there some tool out there that you used? Or maybe you wrote your own little snippet to do that.
     
  29. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I think I found a bug. I create a 4x4 grid. I rotate it 90 degrees around the Y axis. If I then regenerate the grid, the hexes are pointing the wrong way.

    Screencapture at http://screencast.com/t/L4bmgoUy
     
  30. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    The grid should not be rotated.

    It has been quite some time since I made those samples so I can't really remember how that was made. In Battlemass (where those tiles come from) I had an algorithm to create a layout of tiles. I also set my grid snapping to values that will allow me to move the tiles while holding Ctrl and they snap into the right offsets. For the tiles in that sample it is "0.866" on the X and "0.75" on the Z.
     
  31. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I am new to Unity. Can you point me to the location where I can set that please?
     
  32. tomworcom

    tomworcom

    Joined:
    Dec 27, 2011
    Posts:
    50
    I wrote my own, some basic stuff like spawn, move unit, show neighbours.
    At the moment they are quite specific to what I'm doing but I thought about rewriting them in a bit more general style.
    What I haven' t figured out yet is how to deal with the custom NaviUnit class in a more generic way, so I don't always have to call it via my own namespace. Inheriting from NaviUnit for your own purposes seems to be the logical thing, but then I have to couple it to my custom PlayMaker actions.

    @Leslie: Thanks for your answers. I'm actually using TileEd already, just thought UniRPG would also be grid-based, so my mistake.
     
  33. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    How do we make our own TileNodes? I imported an FBX and attached the TileNode script to it but it doesn't work. I added a mesh collider to it as in the documentation, but that didn't fix it. It will produce only Node 0
     
    Last edited: Feb 26, 2014
  34. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    Sorry for all these questions, but I am just a beginning programmer and this is all new to me.

    Looking at your asset's directory structure you have a Scripts directory that has three folders in it. Common, Sample, and TMN. My thought that the TMN folder contains the scripts that are the core of the asset and that the scripts in the Sample folder were just that -- samples. If that is true does that mean that the TMNController script, that is in the Sample folder, is just a sample, and not part of the "core"? And I see that you also have a GameController script that inherits from the TMNController script. It looks like such a file is also necessary for the game to function, but it doesn't look like there is a "bare minimum" example that we can use as a basis for our own custom Game Controller.

    Basically, I am thinking that for my own game, I am expected to write my own GameController and my own TMNController scripts. Am I correct?

    I'm also curious if the CameraMove and CameraOrbit scripts are also considered part of the "core", but they aren't in the TMN folder -- they are in the common folder. For example, I have the asset RTS Camera Pro that I was going to integrate. It looks like I will need to rewrite CameraMove and CameraOrbit to do so. Is that correct?
     
    Last edited: Feb 26, 2014
  35. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Check this link, http://docs.unity3d.com/412/Documentation/Manual/PositioningGameObjects.html

    Check in 'Tile Based Map and Nav/Prefabs/tile_nodes' are the nodes I've created. You'r should be have a similar setup to work. But yea, it comes down to simply placing that TileNode script onto it and it should have a collider.

    Not sure if you are confused about this or not but I'll mention it anyway. These nodes can be empty, they an be colliders only. In my samples I choose to have them represent the markers too, as you will see from how the sample prefabs looks. The actual tiles, the art / land/ world of the game, you place before hand and MapNav is like this invisible grid that sits over it and gives meaning to certain spots.

    You can use any of the scripts as yo usee fit and modify them any way you like. The scripts in core is the main files that is the package. MapNav is for generating a grid of nodes that can give you info about itself at runtime.

    The "controller" script is the one picking up on player clicks and asking units to move around, you could do it different if a different method fits better into your game design. The samples are there to show you how to use the functions of the main scripts.

    You can use whatever camera you like in your project. Remember that scripts in the project does not do much if they are not living on an object to give behaviour to. So if you are not placing my cam scripts onto a camera object then they can't influence it. So just ignore them if you are going to use the RTS Camera.
     
    Last edited: Feb 27, 2014
  36. tomworcom

    tomworcom

    Joined:
    Dec 27, 2011
    Posts:
    50
    Hi Leslie,

    I ran into an issue a couple of times now: In the scene view I can't see the node widgets or their connections anymore.
    Setting the options in the Inspector doesn't do anything, neither does updating the scene view Gizmo properties.

    Edit: They are visible in play mode, but when I stop the game, they disappear again.
     
    Last edited: Mar 4, 2014
  37. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Sounds like the bug that was fixed in the last update. Do you have the latest?
     
  38. RogueVapor

    RogueVapor

    Joined:
    Jan 27, 2013
    Posts:
    2
    Hi Leslie,
    Any chance that you could move the Map and Van tutorial videos over to your new youtube channel? They shown as "removed by user" on your original channel.
    Thanks,
    Travis
     
  39. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    They have all been deleted. The tool is quite easy to use and the vids was really just marketing. Let me know what you are having problems with and I'll explain it.
     
  40. RoelBartstra

    RoelBartstra

    Joined:
    Oct 13, 2009
    Posts:
    20
    Hi Leslie,

    I had a couple of question before I buy the tool.
    - In my game I need to know the "weight" of a tile per unit. For example, some units move faster over water than others. Is it easy to give weights to a tile per object? Or is that something that needs to be added?
    - Will it be possible to run a 64x64 square tiled map on a low-end mobile device like the iPad 2?
    - Does it automatically make tile inaccessible if there is a unit on it, or would it be possible to make something where certain units are able to move through tiles with other units on it? Like for example, infantry can move through tiles with infantry, but not through a tile with a tank on it.

    Overall the tool looks really good, and I hope I can use it for my future project :).
     
  41. tomworcom

    tomworcom

    Joined:
    Dec 27, 2011
    Posts:
    50
    @Leslie: I actually found your YouTube videos to be a great resource, especially for new users.
    Any plans to upload them again somewhere?
     
  42. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    There is not a true "weight" based system in place.

    64x64 might be fine.

    Yes, if there is a land unit on a tilethen another land unit can't move to that tile. An "air" unit might still be able though.
     
  43. AxelRantila

    AxelRantila

    Joined:
    Apr 9, 2014
    Posts:
    2
    Hello. I'm still learning Unity and this pack so I apologize if this is a simple question, but is there some way to make sure that the units moves instantly from one square to another.
    The way I'm design my game, each units moves between the squares instantly, but then have a cooldown before they move on to the next square
     
  44. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    No, but you could edit the code to do this.
    Look inside NaviUnit.cs. Start at the MoveTo() function and look at what it and the functions it calls to, like _StartMoving(), does. You will see I use iTween to move the units so you want to rip that code out and simply update the unit's position with the target node position.
     
  45. AxelRantila

    AxelRantila

    Joined:
    Apr 9, 2014
    Posts:
    2
    Thanks for the quick reply!
    And I'll try and do what you mentioned, in worse case scenario I can probably do some ugly hack to fix it.

    I'll be sure to send you some screenshots of what I'm working on when I have something to show
     
  46. Morgen

    Morgen

    Joined:
    Jan 2, 2013
    Posts:
    11
    Hello, Leslie!

    If you are planning to release any updates to TBMN, I can suggest a small improvent that can save some mesh triangles for people, who are using deafault assets from your package.

    Right now TileNode_Hex prefab in you package has a mesh with 7 vertices and 6 triangles like this


    But you can use a mesh with 6 vertices and 4 triangles like this


    Pretty useful, saves me 1600 vertices and 3200 triangles on a 40x40 location.
     
  47. Morgen

    Morgen

    Joined:
    Jan 2, 2013
    Posts:
    11
    One more thing. I've been looking for some optimizations and playing with profiler and noticed an interesting performance issue.

    I have i dual-core 1.5 Ghz tablet with Mali 400 GPU. It's not the fastest, but it's good for testing for low-budget hardware. I tested this feature on 30x30 or smth. like this hexagonal field.

    The problem is - MapNav.GetPath on it's first call uses around 22ms of CPU time, which is pretty bad, but ok since on each next call it uses only around 1,5ms. But TileNode.ShowNeighbors degrades really bad. If I use DrawRadius of 2 - it's ok. But if I set it around 10, this script consumes 450 ms of CPU. With my default value of 6 it uses around 40-50ms, which is a little noticable when the game runs on 50 FPS.

    The strange thing is that when my character starts moving and I call CurrentTileNode.ShowNeighbours(DrawRadius, false); - it takes so much time, but when my character stops and I call CurrentTileNode.ShowNeighbours(DrawRadius, TileNode.TileType.Normal, true, true); it runs much faster - 10ms script and 34ms Physics with DrawRadius 10.

    I tried to create a method overload like
    public void ShowNeighbours(int radius, TileNode.TileType validNodesLayer, bool checkMoveMod, bool checkOnOffSwitch, bool show)
    {
    List<TileNode> closeList = new List<TileNode>();
    this._ShowNeighboursRecursive(radius, show, validNodesLayer, checkMoveMod, checkOnOffSwitch, ref closeList);
    }
    and call CurrentTileNode.ShowNeighbours(DrawRadius, TileNode.TileType.Normal, true, true, false);
    but nothing changed.

    To my shame, I can't clearly understand what the problem is. With additional profiling Unity shows that this code is causing this behaviour:
    if (closeList.Contains(node))
    {
    if (node._ShowNeighboursRecursive_Helper >= radius) continue;
    }
    I don't know why...

    So, conclusion! =)
    Luckily, my maps are basically roads and passages, so if i completely remove all nodes, that are not reachable (links to them are turned to off), things gets a lot better (but it will be hard to add new nodes later in some case), but in other cases it's pretty bad.

    It's possible, that I use your methods not as they supposed to be used.

    The first picture is when I try to hide nodes
    $Скриншот 2014-05-01 20.16.35.png

    And the second - when I try to show
    $Скриншот 2014-05-01 20.16.38.png

    Thanks for your time and your TBMN! ;)
     
  48. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Keep in mind that this kit was made for turn based use so it is not optimized for real-time path finding and such.
     
  49. Morgen

    Morgen

    Joined:
    Jan 2, 2013
    Posts:
    11
  50. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Added new video...