Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. 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,146
    The units provided (art and scripts) are just samples to show a posible use of the map&nav core system.
     
  2. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    do you have a simple example of the AI​​?
    I am very interested in your package and important understand how difficult it is to connect the AI
     
  3. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    This package include no AI, only basic path fiding (an implementation of a*).
     
  4. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    you add the AI​​? maybe someday?
     
  5. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    There are no plans to add any further features to this package.
     
  6. Player2D

    Player2D

    Joined:
    Feb 2, 2013
    Posts:
    50
    OK I understand.
     
  7. Wenceslao

    Wenceslao

    Joined:
    Feb 7, 2009
    Posts:
    142
    Hello Leslie Young. I purchased your Tile Based Map Nav package last month and I'm enjoying it. I'm building my game on top of it and changing it to suit my needs and such and as I did I found a very subtle bug in _GetAllInRangeRecursive and after I fixed it the function worked for me just fine so I wanted to share. The issue is near the very end of the function:

    Code (csharp):
    1.  
    2.             // this node seems fine, incl in return list
    3.             retNodes.Add(this);
    4.  
    The code goes through and determines whether "node" is a valid neighbor but in the return list you add "this" instead. What this means is that on a hex map, with a range of 1, instead of returning the 6 nodes that are all neighbors to the one you called the function on, instead you will get a list that will have 6 nodes in it that are all the node you called the function on originally. You'd want to change to code to read:

    Code (csharp):
    1.  
    2.             // this node seems fine, incl in return list
    3.             retNodes.Add(node);
    4.  
    So before the fix your list if you called:
    Node53.GetAllInRange(1, TileNode.TileType.Normal, true, false, true);
    The returned list would be:
    [Node53, Node53, Node53, Node53, Node53, Node53]

    After applying the fix, you'll get the proper results:
    [Node31, Node32, Node52, Node54, Node73, Node74]

    If this has already been fixed, kudos, if not it's an easy one. I'm enjoying the package, thanks, it has been very helpful.

    Here's the code:

    Code (csharp):
    1.  
    2.     private void _GetAllInRangeRecursive(int radius, TileNode.TileType validNodesLayer, bool checkIfUnitInWay, bool inclMoveMod, bool incLinkCheck, ref List<TileNode> helper, ref List<TileNode> retNodes)
    3.     {
    4.         this._ShowNeighboursRecursive_Helper = radius;
    5.         helper.Add(this);
    6.  
    7.         radius--; if (radius < 0) return;
    8.         int r = radius;
    9.  
    10.         foreach (TileNode node in this.nodeLinks)
    11.         {
    12.             if (node == null) continue;
    13.             if (helper.Contains(node))
    14.             {
    15.                 if (node._ShowNeighboursRecursive_Helper >= radius) continue;
    16.             }
    17.  
    18.             r = radius;
    19.  
    20.             if (validNodesLayer > 0)
    21.             {
    22.                 // check if this is a valid node according to its mask
    23.                 if ((node.tileTypeMask  validNodesLayer) != validNodesLayer) continue;
    24.  
    25.                 if (checkIfUnitInWay)
    26.                 {
    27.                     // only allow one unit per tile?
    28.                     if (node.mapnav.oneUnitPerTileOnly  node.units.Count > 0) continue;
    29.  
    30.                     // also check if another unit is occupying the same layer, which makes this node invalid
    31.                     if (node.GetUnitInLevel(validNodesLayer)) continue;
    32.                 }
    33.             }
    34.  
    35.             // check if movement mod applies
    36.             if (inclMoveMod  node.movesMod != null)
    37.             {
    38.                 foreach (TNEMovementModifier.MovementInfo m in node.movesMod.moveInfos)
    39.                 {
    40.                     if (m.tileType == validNodesLayer) r -= m.movesModifier;
    41.                 }
    42.                 if (r < 0) continue;
    43.             }
    44.  
    45.             // check if link possibly off
    46.             if (incLinkCheck)
    47.             {
    48.                 if (!this.LinkIsOnWith(node)) continue;
    49.             }
    50.  
    51.             // this node seems fine, incl in return list
    52.             retNodes.Add(this);                                     // <----- The bug is here.  Change "this" to "node"
    53.  
    54.             // on to the next
    55.             if (r > 0)
    56.             {
    57.                 node._GetAllInRangeRecursive(r, validNodesLayer, checkIfUnitInWay, inclMoveMod, incLinkCheck, ref helper, ref retNodes);
    58.             }
    59.         }
    60.     }
    61.  
     
  8. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    Thanks. Will include in next update.
     
  9. Dinrae

    Dinrae

    Joined:
    Dec 19, 2012
    Posts:
    29
    Hi,
    I would be interested by your package, but before buying it, i would like to know if:
    - Can it be used to place, let's say, like building on runtime, and those buildings can be 2x4 squares.
    - It is possible to save/load tile datas.
    Like you can see, the only thing i'm interested in your package is the tilemap system to place buildings/props. Characters won't be affected by tilemap.

    Thanks in advance.
     
  10. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    Yes, you can place anything at runtime. If you place something like a building which is 2x4 then you would just have to set all the tiles under it as being occupied (for example setting them to being Wall type tiles) so that the units movement code won't steer units through it or so that you can't pick those tiles again for future bilding placement.

    The spawn code (which you might use to palce the building) do not know how to set more than one tile as being occupied but you can easily cast a few rays from 8 positions (2x4) of the building to see which tiles are affected and then ste them.

    There is nothing build in that load/save tile data but I suppose you could create something that runs through all tiles to get the important info from them, like what are on them, and save it to playerprefs.
     
  11. _-MADMAN-_

    _-MADMAN-_

    Joined:
    Nov 3, 2009
    Posts:
    40
    Hi there,

    First of all - good packcage, saved a lot of time - thanks!

    One question - as we can see object-per-tile approach is quite heavy, do you have any idea how can I use your system for bached movement?

    Here is the explanation. Unit has it's range and your code activates only hexes in that range (so player can move around them). I want to let player click somwhere faaaar far away from him, and each turn unit will automatically move to target pole if moves available.

    Simple thing, I don't need any deep explanation, just want to know if such a thing is already implemented. If not - I will figure it out on my own, but advices are welcome. At the moment the only option I found is to turn on whole grid, but I'm using up to 100x100 map.

    Also I want to share two optimizations I have made (for those that are fighting with performance too :)):
    - I think that sphere collider is way better (and cheaper) option instead of mesh collider from example
    - Renderer attached to each tile isn't a cheap solution too - I'm using tiles only with collider and node class, then I'm drawing grid on my own

    All best!

    Artur
     
  12. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    You could activate only the neighbours around a far away point, in the same way that nodes around the selected Unit is activated. You would need to change the code for a Unit so that it does not activate the nodes around the unit, if you don't want that. Check the function OnNaviUnitClick() in the sample GameController.
     
  13. _-MADMAN-_

    _-MADMAN-_

    Joined:
    Nov 3, 2009
    Posts:
    40
    Thank you for fast response!

    Just to make it clear - if between destination point and unit are 'inactive' (invisible) nodes, nav will be able to search trough all of them?
     
  14. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    Yes, you can use the nodes if they are "inactive". The enable is really just to activate the colliders that you wnat the player to be able to click if you use that method. You could even keep them all on if you wanted and had another way of checking f the player chose the correct node. Also, the node markers are bound in this make active/inactive system.
     
  15. _-MADMAN-_

    _-MADMAN-_

    Joined:
    Nov 3, 2009
    Posts:
    40
    Thank you, really appreciate your help.
     
  16. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    827
    Leslie,

    from your experience, does GetPath() always return the same path even if there are multiple paths with the same cost to reach the target? I am thinking about adding a way to highlight the path my unit will take from its current point to the target while hovering above the target tile but that would require that the path is always the same during every test.
     
  17. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    Yes, it should not change since it is the same logic calculating the path each time. So same nodes are checked in a certain order and can thus not have different results.
     
  18. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    Hi, im thinking of buying this tool for a rogue like game and had a usability question. I want to be able to let the player drop items on teh ground, would making all of the items units make sense so that i could use the nodes to keep track of them? I could also write some custom code to do this, perhaps add a new layer? I'm just wondering your thought on how this could be done, and if it would even be useful to leverage the map system.
     
  19. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    I guess inhereting a new class from NaviUnit can't hurt and then you got the tileLevel and linking code allready defined. Just make sure that the tileLevel you use with items is not the same as with "units" else if you use my moving code your units won't be able to move over tiles that has items on them since the unit will think there is another one on that tile.

    The movement code checks what is linked with the node, TileNode.units, and then check the NaviUnit.tileLevel to see if it is something on the same "level" as the unit trying to move there to determine if it is blocking movement. This is in place of layers. Layers are only used with the raycasts that detect what you have clicked. Internally I have an enum like this which you can modify and then masks NaviUnit.tileLevel to determine what level the unit is on, on the tile - floor, air, water, wotever else you define.
    Code (csharp):
    1.  
    2. public enum TileType
    3.     {
    4.         // you can add/remove as you like, just make sure to use 2 to the power for values to follow
    5.         Normal      = 0x1,  // 1 normal/land tile (land and air units can move over it)
    6.         Air         = 0x2,  // 2 only air units can move over these tiles
    7.         Water       = 0x4,  // 4 water tile, only water and air units can move over it
    8.         Wall        = 0x8,  // 8 a wall/obstacle, nothing can move onto this tile
    9.         //etc       = 0x10, // 16
    10.     }
    11.  
    If units can move over these items then I would not even bother linking them with TileNode. Just keep a seperate list "items on the floor" and those items can track the nodes they are on without making a hard link to the nodes. Making them units is possible too like I explained above, and does ot really matter.
     
    Last edited: Feb 19, 2013
  20. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    So i purchased the package and imported everything, but it seems that none of the samples run, they all have trouble finding behaviors of some kind. Has anyone else experienced this issue?
     
  21. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    "behaviours"? No idea what that is.
    Can you please post the exact error message you are geting in the unity console so Ican see what lines in the source this is happening on.
     
  22. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    Monobehaviors, or scripts. Basically it seems like many of the links between script and components as well as meshes and materials within the prefabs have been lost for some reason. I wonder if its a Unity4.0 issue.
     
    Last edited: Feb 21, 2013
  23. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    I;ve just imported map&nav from the asset store into a new/clean project in unity 4 and the samples are working fine. Perhaps you have another package or code in your project that is causing problems? I tested on Windows but I can't see how it will differ on OSX since this package doesn't do anything strange that would cause it to not work on OSX.
     
  24. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    OK thanks, must be on my end, ill give it another go with a new clean project tonight.
     
  25. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    Forget my issue, it was a problem with SVN and metafiles, not a problem with the package.
     
  26. cmo

    cmo

    Joined:
    Aug 10, 2012
    Posts:
    13
    I've taken a look at TNEMovementModifier and found that it's implemented very oddly -- it apparently only affects pathing and does not deduct from currMoves. Is that right, or am I missing something?

    How would you suggest implementing proper move deduction for the script? I can't quite wrap my head around how to convert out "G" in GetPath to actual move points. I'm considering having the unit check the mask of each node it links with and deduct additional moves based on that mask, but that just seems like a really wonky solution that will break as I implement additional features.

    Like one of the commenters a few threads back I'm also frustrated with how manual TNEMovementModifier is compared to the other tools in the package, but I'm just solving that by dumping it on every tile and having it run a Start function that sets the movesModifier based on mask.
     
  27. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    TNEMovementModifier was created to increase the amount of moves it takes to move over a certain tile. For example, it might take one movement point to move over normal tiles while it might take two to move over a "Swamp" tile. By placing this modifier on a tile you can tell how many moves it takes to move over that tile.
     
  28. Parallel_

    Parallel_

    Joined:
    Dec 9, 2012
    Posts:
    90
    Would it be setting ones hopes to high; dreaming of triangular, pentagonal or n-gon tiles- added as grid basis here?
     
  29. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    Sorry, there are no plans to add other grids.
     
  30. cmo

    cmo

    Joined:
    Aug 10, 2012
    Posts:
    13
    OK.. thanks, but that does not answer my question. You're basically telling me that TNEMovementModifier takes the max moves of the unit into account when calculating where it can move but doesn't adjust remaining moves afterward.

    What I'm asking about is the case in which a unit does step on the tile instead of pathing around it. In any game I've ever seen that includes move points, stepping on a tile that requires more move points would actually deduct those move points, Instead TNEMove just seems to require the move points (like having to have a certain bank balance to qualify for a house) but not deduct them..

    So, yeah. I guess I can't see the purpose of TNEMove as it was implemented.
     
  31. Dark-Muppeteer

    Dark-Muppeteer

    Joined:
    Feb 24, 2013
    Posts:
    26
    Sorry if this has previously been asked; I've skimmed through all of the pages and didn't see anything.

    I'm wondering if there is any easy way to restrict units to specific path types, such as having a unit that can only travel in straight lines or one that only moves along diagonals?

    As a comparison I'm thinking along the lines of how the different pieces of a chess set can be moved.
     
  32. adigleria

    adigleria

    Joined:
    Aug 19, 2012
    Posts:
    4
    EDIT: Looks like I was just picking the wrong object type. Browsing this forumn I was not alone in this screwup. Thanks to the developer for replying also.

    Basically, system is dying creating a new map on line 289 of MapNav.cs:

    Runs ok:
    TileNode n = go.GetComponent<TileNode> ();

    Next line gets null reference error:
    n.idx = count;

    I would have thought GetComponent with no parameter would return null, so the next line is going to fail when it accesses n. I'm new to Unity so I may be missing something, (or maybe I didn't enter the info correctly in the custom mapnav dialog box) so any help appreciated.

    Full error:
    NullReferenceException: Object reference not set to an instance of an object
    MapNav.CreateTileNodes (UnityEngine.GameObject nodeFab, .MapNav map, TilesLayout layout, Single tileSpacing, Single tileSize, TileType initialMask, Int32 xCount, Int32 yCount) (at Assets/Tile Based Map and Nav/Scripts/TMN/MapNav.cs:289)
    MapNavCreateWindow.CreateMapNav () (at Assets/Tile Based Map and Nav/Editor/MapNavCreateWindow.cs:76)
    MapNavCreateWindow.OnGUI () (at Assets/Tile Based Map and Nav/Editor/MapNavCreateWindow.cs:57)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
     
    Last edited: Feb 26, 2013
  33. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    I do not understand what it is you are trying to do.

    For TNEMovementModifier, have a look at the sample01 scene. The tiles with the green dots on them require an additional move point to move over. See how ground units react when moving around those tiles. maybe it will better explain what this modifier does. If it is not exactly what you wnat you could have a look at how TNEMovementModifier is use in the code to create your own one.
     
  34. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    There is no code to calculate such paths. I'm thinking the easiest way to figure out straight and diagonal is to make assumptions about the neighbour linking of each node. For example, if you could assume the 1st link is always left of the node then things would be easier. This is not a feature I support but I think you can make the assumption as the linking code works in a certain order. Have a look at LinkNodes() in MapNav.cs
     
  35. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    You use something other than a TileNode prefab as prefab in the TileNode Field of the MapNav object and that is why the component is not found (cause it is not on the prefan you used).

    The sample TileNode prefabs are located in "\Assets\Tile Based Map and Nav\Prefabs\tile_nodes"
    Any custom TileNode Prefab you make must have the TileNode component on it.
     
  36. Aranhawebs

    Aranhawebs

    Joined:
    Jul 29, 2012
    Posts:
    7
    I’ve just bought the Map and Nav on the Unity Asset Store, and i`m having some troubles with the initialization of the game. I saw the documentation, but it only talks about the creation of the map and changes on the masks. I was wondering if you have some documentation that talks about the Main object, GameController script and how to instantiate the units. Thanks.
     
  37. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    Map&Nav is about the MapNav and related classes and not a framework for making a specific game, so I do not document and explain the samples as I do not expect you to base a real game off of them. They are there to show how to use the functions in the core scripts, mapnav, tilenode, etc.
     
  38. theotherkaki

    theotherkaki

    Joined:
    Aug 28, 2012
    Posts:
    12
    I bought this package and watched all of the videos, but it seems that some more things have changed that i havent seen in the videos. I am still making my way through the code though, and may find answers there.

    one thing i would like to know (having not read the code yet) is how easily this could be changed to a 3d node grid, for example a 50 by 50 grid that is 4 layers high, and units can move in 8 directions horizontally and 2 or more vertically. If you have played X-COM (the original) you should know what i want to do.
    another is how walls between tiles would be calculated. my 1 year old baby had a blocked nose last night, and that gave me plenty of think-about-the-game-while-soothing-chibi time. however, each tile node must 'own' the terrain assets, and know if a wall has been destroyed so as to open the links to other nodes... i can see this getting a bit complicated in that each node would then need 8 'slots' for each wall...
    This is a nice package and where the documentaion is lacking a brain can make up for. Thank you.

    And i love your accent in the videos.
     
  39. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    It would require a lot fo changes to support a 3D grid. Easiest might be to just have a few mapnav's on top of each other to simulate the 3D. As long as they are the same size you should be able to calculate where in the 2nd, 3rd, etc grid's nodes you want to be. (I've never played any x-com)

    I do not understand the wall question, especially the 8 slots part threw me off.

    The accent is from speaking Afrikaans as a 1st language.
     
  40. theotherkaki

    theotherkaki

    Joined:
    Aug 28, 2012
    Posts:
    12
    The original X-com was great, and it has made me obssessed with destructible terrain...
    In your dungeon samples walls are the thickness of tiles and units can't move into tiles with walls or other obstructions. What I am thinking of is thin walls which occupy one edge of a tile so that units can move into the tile, but not to the tile on the other side of the wall. In a 10 by 10 grid all 100 tiles would be enterable but movement would be restricted by the walls. This could obviously be done by initially turning off relevant node links and having them re-enabled if the wall is destroyed, but a tool like the ones you made for this asset would make doing that so much easier.
    The 8 slots thing meant the six sides of a hex and the roof and floor, but then it occurred to me that you would only need half of that because tiles fit together, and you dont need 2 walls between tiles. Objects would include an upper right wall (north), an upper left wall (west), a floor, and a destructible object that occupies the tile. If the tiles had a script which held these objects, and the wall mesh took damage and was destroyed, the tilenode would then re-establish links between itself and the tilenode on the other side of the wall to allow you to pass through the hole you just made.
    Of course, this can all be avoided with a change in art style/design, but we don't always have that choice...

    As I bought your package more out of curiosity than necessity, I can probably make this myself, but I thought that it would make your product even sexier. And I like the sound of myself typing...
    View attachment 45884
     
  41. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    827
    I am not sure whether the walls in X-COM are linked to a specific side of a node or if there's something like a second grid of nodes on which the game places wall pieces instead so nobody has to worry whether a wall is on the left of node1 or the right of node2. In the TM&N environment a wall prefab would ideally include a script that tests for nodes on either side, possibly via two colliders or raycasts, and deactivate the link between those two nodes.
     
  42. theotherkaki

    theotherkaki

    Joined:
    Aug 28, 2012
    Posts:
    12
    The way I had originally envisioned it is that each object or wall would have its own collider, and if a stray shot hit and destroyed it, it would report this to the node which would then change its properties/links accordingly. However, the initial set up would be quite a job... It certainly would be easier to have the wall prefab find and turn off the links at start up, and turn them back on when destroyed.

    The picture I drew didn't show up on the last post.

    $walltypes.png
     
    Last edited: Mar 7, 2013
  43. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    827
    I don't see how this wouldn't be possible. Like I said, on startup a wall prefab would cast a ray at both sides on the Tiles layer and deactivate the link between those two it finds, and reactivate it again when it's destroyed. I am not sure about how much time an initial setup would take, but that's what loading screens are for.

    Thinking about it, you should probably should assign hitpoints to the walls and check it against weapon damage unless you want to be able to take down a house with a pistol. ;)
     
    Last edited: Mar 7, 2013
  44. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    I think c-Row got the same idea of how I would handle it too cause I can't really see how else tmn would know where the walls are (in an auto-magic way).

    In the MapNav class you will notice the call to LinkNodes in Start(). Changing LinkNodes(), from line 320, will probably be the best place to modify the links since this is alrleady running through all the nodes.

    You should be able to figure out which tile links are being checked from the comments I added to this function and then cast the correct rays before finally deciding to make the link or not. A very short ray from the center of the current tile to the center of the neighbour should be enough to check. Remember to cast it a little higher than the tile's exact center ;)

    Since a wall can be destroyed it will prbobaly be a seperate object with its own script to detect and handle being shot at (bullet colliding). The Wall needs to know which TileNode it sits on. This linking can be done in the LinkNodes function too. I would skip linking if I detect that the wall is allready linked with a node (since it sits between nodes and can belong to on of two nodes). I would also tract which tile is the "neighbour"and add a Wall list to the Tilenode class (to be used later) and add walls to it that belongs to it.

    When a wall is hit I would then tell its TileNode that it was hit. The TileNode can then unlink with the neighbour that was stored in the Wall without having the cast rays around it to see which walls are down and still up.
     
    Last edited: Mar 9, 2013
  45. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    827
    Great minds think alike. ;)
     
  46. ddesmond

    ddesmond

    Joined:
    Feb 9, 2010
    Posts:
    163
    For some reason, I am getting this error:

    NullReferenceException: Object reference not set to an instance of an object
    MapNav.CreateTileNodes (UnityEngine.GameObject nodeFab, .MapNav map, TilesLayout layout, Single tileSpacing, Single tileSize, TileType initialMask, Int32 xCount, Int32 yCount) (at Assets/Tile Based Map and Nav/Scripts/TMN/MapNav.cs:289)
    MapNavEditor.OnInspectorGUI () (at Assets/Tile Based Map and Nav/Editor/MapNavEditor.cs:138)
    UnityEditor.InspectorWindow.DrawEditors (Boolean isRepaintEvent, UnityEditor.Editor[] editors, Boolean eyeDropperDirty) (at C:/BuildAgent/work/812c4f5049264fad/Editor/Mono/Inspector/InspectorWindow.cs:863)
    UnityEditor.DockArea:OnGUI()

    I added the island and added the MapNav component. Set the layers, wxidth to 40x40 and pressed create, am I missing something?
     
  47. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    Not sure why you would get the error at line 289 since that line is just a bracket, except if you got an older verison of mapnav.

    Anyway, the next line has to do with instantiating the node prefab. Did yo uassign a node prefab like TIleNode_Hex or TIleNode_Square from \Assets\Tile Based Map and Nav\Prefabs\tile_nodes; or if you are using your own prefab, is it actualyl a node prefab (have the TileNode component on it)?
     
  48. ddesmond

    ddesmond

    Joined:
    Feb 9, 2010
    Posts:
    163
    Sorry, I found the issue, I was trying to use multiple assets and forgot the tilenode.
     
  49. theotherkaki

    theotherkaki

    Joined:
    Aug 28, 2012
    Posts:
    12
    Back again, with another question. I am reverse engineering your system and have implemented a 3D grid system with node links, the prefab auto-switch off links and switch on when destroyed bit, and one-node-at-a-time unit movement. I am now getting into the path finding part so as to move units over a distance.
    While I can mostly read C#, I am working in UnityScript for convenience while I learn more about C#. You have a line in mapNav (136) else if (ol.PathF < tn.PathF) tn = ol;
    I know what you are doing, but I don't get why tn and ol have a .PathF when those variables aren't in the TileNode script. Perhaps they have something to do with System.Collections or Generic? I am only 2 years old, but if you could point me in the direction of what to read I would be grateful.

    After further looking, I believe thay may be properties, which UnityScript doesn't have... So to emulate that I just use variables?
     
    Last edited: Mar 16, 2013
  50. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    Yes, they are properties which are defined at line 569 of TileNode. In UnityScript normal public variables will be fine since these don't do much more than prevent you from setting the variable outside of the TileNode class (thus the "private set;" in the definition). When you run into a property that does more you could replace it with a function in UnityScript. Another reason I use C# properties is that I can make them public and access them like variables without Unity showing them in the inspector like it does for public variables and I don't have to use [HideInInspector].