Search Unity

Dynamic AI Project Help Page

Discussion in 'Community Learning & Teaching' started by brilliantgames, Nov 23, 2012.

  1. Durston88

    Durston88

    Joined:
    Mar 15, 2012
    Posts:
    110
    Don't think that's entirely fair. Response times do seem to be a problem, but I've been using this for about 2 weeks now and have yet to get any problem with the asset, whether it's using the grid itself or incorporating it into other scripts. I've got a working grid for my level along with obstacles, and have successfully (and somewhat easier than expected) gotten the pathfinding to work in my AI state scripts, and also using this for a simple patrol-path system with empty gameobjects acting as markers with the GridPosition script. So I can't agree that it's "buggy as hell". This is a pretty good asset but the support response times don't seem to match, might be because there are two threads and the other one gets more activity.

    CodeAthei, I remember getting that issue before but I'm not anymore. I don't remember what it was but if I can recreate it I'll let you know.
     
  2. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    I apologize for my absence on these forums. I was away for a while on a trip and had very little computer access.. I also want to apologize for the lateness for the next update. The trip I had kinda messed things up.



    You must have some extra colliders hanging around in your scene. For the current beta version you are using there is only one ignore collision layer, there will be multiple in the next update. Theres little I can do for the slowness of debugging, getting a visual of the grid requires thousands of lines to be drawn, theres really no way around it.. Try to understand that you are using a beta version and most of the reported bugs have already been fixed. Its just a matter of putting the finishing touches and preparing it for release.

    I am heading out the door right now, but I will get to the rest of everyone's questions in a bit. Thank you for your patience.
     
  3. Kryptex

    Kryptex

    Joined:
    Jan 5, 2013
    Posts:
    8
    Hey there!

    I just bought this from the Asset Store today, and at first I was very happy. Now though, I have been having problem after problem in getting the pathfinding to work correctly.

    I have used playmaker to create a "point and click" move system. (Like Fallout 1/2) I was hoping to use this as a pathfinding solution, where I can use playmaker to place a dummy target where I click and feed the scripts the information on the target's location. (This part works, sometimes...)

    My main issue right now, is that when my character is moving along his path, whenever he reaches a....not sure what to call it, new angle or point...he just starts spinning. Sometimes when I click the target to a new location he will stop and move some more, only to start spinning again.

    I've tried toying with all of the settings, and nothing seems to be working...Please tell me you have a solution for this!!! :p

    Thanks ahead of time!
     
  4. skylerkingdev

    skylerkingdev

    Joined:
    Sep 10, 2010
    Posts:
    36
    I am having the same issue Kryptex, the random movement script seems to be the only bit of this kit giving me problems. My agent navigates to the first waypoint, then spins in circle instead of moving forward to the next waypoint. Even copy-pasting the ai character from the demo yields the same results. Anyone figure out what's missing here?
     
  5. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    PM sent.
     
  6. maidamedia

    maidamedia

    Joined:
    Nov 19, 2009
    Posts:
    219
    In the last part of the video tutorial you say to remove Navigation and Navmeshtarget scripts and to apply the fantasy plugin. Does this procedure apply also to the player character? Thanks
     
  7. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    For the player all you really need to have is the grid position. Remember that script is required for all targets being navigated.
     
  8. maidamedia

    maidamedia

    Joined:
    Nov 19, 2009
    Posts:
    219
    So all the Fantasy AI scripts plus the Grid script. Right?
     
  9. GattsGK

    GattsGK

    Joined:
    May 5, 2013
    Posts:
    18
    Hi! I have not spend too much time yet playing with this asset, but I can't find the way to set a Vector3 location as target position...just follow other transforms. I've read a previous comment about this, but no answer...is something planned for a future update?
     
  10. GattsGK

    GattsGK

    Joined:
    May 5, 2013
    Posts:
    18
    Hi again!

    I have a GameObject that is created on runtime and should be avoided on paths. I attach to it the DynamicObstacle script and the path is well calculated. But now I want to get near the object when I click on it. So in one hand, if I delete the DynamicObstacle I can get near the object, but the calculated paths go through that object. In the other hand, if I set the DynamicObstacle the object is avoided when running, but the path is interrupted if I set that object as target object.

    Is there a way to achieve what I want to do or should I do it on my own.

    Many thanks!
     
  11. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    Sorry, just need to get a better understanding of exactly what you're asking. You want to target an object that is also a dynamic obstacle?
     
  12. GattsGK

    GattsGK

    Joined:
    May 5, 2013
    Posts:
    18
    Hello,

    Yes, exactly. But don't worry, I am writing my own script (almost done, just fine-tuning left) for that purpouse ;-)
     
  13. andywatson00

    andywatson00

    Joined:
    Dec 26, 2012
    Posts:
    5
    Hi, I just started using dynamic navigation and has been working fine but i am trying to setup a patrolling system for my AI where they will follow a path of predefined targets but when i give them an exact location to go to i am getting some undesirable behavior.

    In the image below the magenta line is the path I would like the AI to follow and obviously the green line is the path it has picked along with the red bit at the end. Currently my AI never makes it to the desired point it only goes to the end of the green section of the line which is currently no where near the target.


    $path.jpg


    So my question is why would my AI not go to the exact location i specified, what is the significance of the red part of the line and why is it choosing a much longer path than it has to take?
     
  14. CaptainChristian

    CaptainChristian

    Joined:
    Apr 3, 2013
    Posts:
    97
    Hi,

    I got a really huge terrain and am running into some problems. When I increase the grid size to encapsule all terrains stitched together it takes a really long time to compute and usually results in a crash. However when I increase cube size and grid size things don't seem to work properly. Areas that should be walkable are colored nonwalkable and some terrain doesn't show any marks at all. What grid properties do you recommend for huge terrains?
     
  15. ZeoWorks

    ZeoWorks

    Joined:
    Dec 13, 2012
    Posts:
    76
    So far its working great! However, when a new prefab enters the scene it does not work or path find (This is using the standard AIMove script). Also the grid prefab is spawned and *created* at runtime. Please help! thanks.
     
    Last edited: Jul 6, 2013
  16. Michael316

    Michael316

    Joined:
    Aug 2, 2012
    Posts:
    16
    Hello, just made the switch from the other pathfinding plugin and I'm getting these two errors:
    NullReferenceException: Object reference not set to an instance of an object
    GridPosition.Update ()
    NullReferenceException: Object reference not set to an instance of an object
    Navigator.Update ()

    I'm not adding anything at runtime, and I'm using the prefab AI-Character (and I also tried the AI-Capsule) from the warehouse scene. I've added a grid to both the GridPosition and Navigator scripts. I've got it set up about as basic as can be, still getting the errors. Any thoughts?

    EDIT: Is it possible this plugin isn't playing nice with other plugins? Are there any known issues? I was able to get it working in a new project, but my existing project is throwing the above errors.

    Michael
     
    Last edited: Jul 10, 2013
  17. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    If there are any scripts with the same name this is very possible. And considering you have another pathfinding pluggin present it sounds even more likely to have scripts named 'navigator'.
     
  18. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    Are you giving the AI targets to follow? Do those targets have 'gridposition' scripts attached to them? This is very important. Remember, the grid position script shows a red line showing which current node it thinks is the closest node to itself. So it will bass this on how it will go about finding its path. Make sure your target nodes are connected with the correct nodes you wish for it to go to.
     
  19. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    Yes you have to work with as large cube size as possible. When you are making grids above 1000x1000 you are dealing with a very large amount of memory here.. Remember you must adjust your other settings to go with your cube size. The help page at the beginning gives you pointers for these settings. Your capsule size and slope height are probably too small for your cube size.
     
  20. CaptainChristian

    CaptainChristian

    Joined:
    Apr 3, 2013
    Posts:
    97
    Which grid size do you recommend? 100x100, 150x150, 200x200? I need to get a feeling for what's right. Sorry to ask these kind of questions.
     
  21. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    Those are all fine. I have made grids up to 1200x1200 and things were pretty stable. How much ram do you have? The amount of layers make a big difference too. Make as little layers as you can.
     
  22. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    Those are all fine. I have made grids up to 1200x1200 and things were pretty stable. How much ram do you have? The amount of layers make a big difference too. Make as little layers as you can.
     
  23. CaptainChristian

    CaptainChristian

    Joined:
    Apr 3, 2013
    Posts:
    97
    I got 8 gigs, so probably 7 gigs of free memory. I somehow got around 1200x1200 to work without crashes (it crashed in the past) and I'll probably stick with that size for testing purposes. Since I am working on a game with really huge terrain sizes, I will probably reduce the grid size to free up some memory in the future. Should I expect any weird behaviour on a mostly open terrain with a grid size of around 150x150 and a big cube size of 20 or higher or can it be even bigger considering the usage of other grids at narrow places like cities?

    Note: I am using standard sizes for my game objects and creating an rts/rpg hybrid with squad-inspired combat.

    Edit: What is the cause of the problem when the debug line going out from a character goes straight to the origin?
     
    Last edited: Jul 16, 2013
  24. CaptainChristian

    CaptainChristian

    Joined:
    Apr 3, 2013
    Posts:
    97
    Sorry for the double post, but I think I found a bug on my end. I've been messing with multiple terrains parented under an empy gameobject. As it turns out, pathfinding works flawlessly when the terrain is not parented. At least that's the conclusion I draw from my observations. Do you consider making your code open source, digging in dlls is not something I want to do.
     
  25. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    Any grid under 1000x1000 should be perfectly stable. But this also depends on your machine. The good thing is it doesnt seem to affect memory very dramatically in builds of your game, more so just in the editor. But I created a simple system where i made multiple grids that overlap eachother, on a large terrain and had a script that checked the distance from the player and switched to the closest grid. But the script had to switch all the AI to that grid if they were targeting the player.

    The reason why my pathfinding is not open sourced is because it does a few things no other pathfinding engine does. There are also alot of unique algorithms I spent hundreds of hours on.
     
  26. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    I also just wanted apologize for the delay on my response. I have had some family emergencies as of late as well as moving. I will put my best efforts into answering questions as fast as I can.
     
  27. CaptainChristian

    CaptainChristian

    Joined:
    Apr 3, 2013
    Posts:
    97
    Edit: I am sorry to hear that. All the best to you and your family.


    I understand.

    Do you plan to release scripts like an advanced grid-switching algorithm and a couple of sample grid sizes (only by their parameters) so people can decide quickly what approach they want given the advantages and disadvantages? I don't want to bother you that much, but since your asset is heavy on the technical side of things, it is not very easy for me to get a grasp of all the potential and functionalities quickly. I am asking these questions, because there are not that many examples to get into by myself.

    I bought both this asset and the Advanced Fantasy AI for a couple of reasons, one being time constraints. I want to spend as little time as possible for the first prototype including your AI packages.
     
  28. Dubious-Drewski

    Dubious-Drewski

    Joined:
    Aug 19, 2012
    Posts:
    51
    After some tinkering, I've noticed that The target can exit the Grid on either side of the X axis, and the pursuing AI will stop at the edge of the navigation grid(This is great), but if the target moves out of bounds in either Z direction, it throws an out of bounds error and halts everything. It would be nice if the AI just walked up to the edge of the Grid, whether it was the X or Z edge, without throwing an error.

    But this is a great asset man! It takes some tweaking and experimenting to get it right, but it works wonderfully! And THANK YOU THANK YOU for writing it in C#.

    EDIT: A strange problem: I've got a flat test plane, rotated at 2 degrees(A very gentle slope). The navigation grid is solid blue. The AI doesn't seem to have the "horsepower" to climb the slope towards the target. It tries to approach, but slides backwards. I don't know how to fix this - even setting the rigidbody mass to 0.01 doesn't work. Help?

    EDIT2: Fix for the problem - Freeze rotation on X and Z axis of the AI.
     
    Last edited: Aug 23, 2013
  29. rufreakde

    rufreakde

    Joined:
    Jan 16, 2013
    Posts:
    36
    Hey I just found this thread and it got my attention! :D

    There are some questions though xD
    1. Is there something like a test version out there because I would need a dynamic grid creation for up to 12 characters.
    2. Its a multi-player game so I would like to have the way points somewhere (like a list or a array) to sync them
    3. Is the dynamic grid creation fast enough for a 120x120 (pref bigger) grid on 60x60 cubes (3600 cubes) that can move up and down?

    I like your Tutorial videos you should make a dynamic grid creation tutorial with stress test :p

    Keep up the good work!

    Cheers ;)
     
  30. TheCheese

    TheCheese

    Joined:
    Nov 25, 2009
    Posts:
    82
    Hi,

    Is there a function I can use similar to Unity's NavMesh.CalculatePath? Basically I would just like to be able to test for the closest point on the grid given a world position. I'm sure this is possible between the Grid and the Navigator, but I can't figure it out.

    Thanks.
     
  31. Shinugami

    Shinugami

    Joined:
    Oct 17, 2012
    Posts:
    52
    Hi,
    I'd like to say thanks for making this great software. I'm enjoying using it. I do have one question. When using the dynamic obstacle script on a gameobject - the 'update grid' check can cause some unwanted results. When the scene is in non-play mode, the grid is perfect, the walkable and non-walkable zones are perfect.

    My problem occurs when the update grid switches to 'on' in play mode. I understand this is needed to update the grid but let's say I have a dynamic object that I want to move around the map. The problem is that when the object moves from it's original location, the original location remains 'not walkable' despite the object having moved. And after I press stop, that part of the map remains not walkable. I can reset the grid and make it perfect again but as soon as I press play, unless I press stop and reset the grid that footprint seems permanent wherever the dynamic object begins on the grid.

    Essentially it works fine except that a footprint of 'not walkable' grid remains.

    Is there anyway to prevent / overcome this? I figure it has to do with the start only so one idea I have is creating the dynamic object during play instead of having it in the scene at start up.

    ***Edit: I did find one solution. If I start the dynamic object in a 'not walkable' part of the grid, the footprint does not exist / is not created and the result is perfect. I will use this work-around until I find a better solution.
    Another solution is to start the scene without having the 'dynamic object' script active and then activate the script during play.

    ***Update 27th April 2014.
    Found another way this problem can occur. If you have DynamicObstacles and they are parented into a gameObject that perhaps you are using just for the sake of organisation, if this parent object does not have an appropriate layer such as 'DynamicObstacles ' you will get a 'non-walkable print when you create the grid.
     
    Last edited: Apr 26, 2014
  32. lofwyre

    lofwyre

    Joined:
    Apr 19, 2007
    Posts:
    140
    Hi

    Recently purchased Dynamic Navigation. It's looking pretty good so far.


    Some initial questions:

    1) Is there a PDF manual or is it just the tutorial videos at this stage?
    2) I have an enemy chasing my player, a portal on the ground and another on a ledge (both open), how do I get my enemy to jump up?
    3) How do I get my enemy to walk instead of run (i'd like to do patrolling and walk, then run when it sees player)

    Thanks
     
  33. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,926
    No all the info and tutorials are here. The portals are simple manual links in nodes on the grid. How you get him to jump is up to you. Maybe make a trigger at the portal where when he hits it have him play the jump animation. Same goes for walking, this is a path-finding solution, not a AI behaviour system. the AImove script is meant to get you started.
     
  34. Shinugami

    Shinugami

    Joined:
    Oct 17, 2012
    Posts:
    52
    @ lofwyre

    For question 3, you need to make a reference to the AI_Move script that you have created or used from the prefabs.
    Just make a variable to hold your speed values and when you want to change the speed just use the reference of the AI_Move script and change the speed. I'll show you my code:
    Code (csharp):
    1.  
    2. // I've left out most of the code to show only what is relevant to the question
    3. #pragma strict
    4.  
    5. private var runMode : boolean = false;  // If urgent, the AI will run instead of walk.
    6. var runSpeed = 3.5;
    7. var walkSpeed = 1.6;
    8.  
    9. // This will hold a reference to my own custom 'AI_Move' script.
    10. private var move : script_AI_Movement_DynNav;
    11.  
    12. // The AI_Move script will talk with the Navigator script.
    13. // You cannot edit the Navigator script but you can edit the AI_Move script.
    14. /* If you look at the tutorial sections you can see what all the parts mean and  
    15.   with enough trial and error you will understand what each part does/doesn't do. */
    16.  
    17. function Start () {
    18.     move = GetComponent(script_AI_Movement_DynNav); // make a reference to my own custom 'AI_Move' script.
    19. }
    20.  
    21. // Call this function whenever you want to adjust the speed
    22. function AdjustSpeed(){
    23.      if(runMode){      
    24.         //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    25.         // Set Speed of Movement engine"
    26.         move.runSpeed = runSpeed;
    27.         //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>        
    28.         }else{
    29.         //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    30.         // Set Speed of Movement engine"
    31.         move.runSpeed = walkSpeed;
    32.         //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>    
    33.     }
    34. }
    35.  
    The explanation of what the components mean is here (under the heading 'Tutorial 2'):
    http://forum.unity3d.com/threads/159725-Dynamic-AI-Project-Help-Page?p=1092936#post1092936
     
    Last edited: Apr 26, 2014
  35. Draco18s

    Draco18s

    Joined:
    Aug 15, 2011
    Posts:
    107
    Is there a good/easy way to check for path connectivity between two points?

    That is, I want to be able to place down obstacles and in the script that is responsible for creating them, I'd like to have a check that after placement there's still a valid path from A to B (basically one side of the map to the other) and if not, destroy the created obstacle and inform the user that they can't place that there.
     
  36. oroddem

    oroddem

    Joined:
    Apr 2, 2014
    Posts:
    1
    Hello, i basically need all the capabilities of Unities built in nav mesh, but i need to be able to create then dynamically at runtime (after the level has been dynamically created at runtime) will this package do what i need?
    Thanks
     
  37. FisherM

    FisherM

    Unity Technologies

    Joined:
    Dec 28, 2013
    Posts:
    366
    I've been trying to get multiple navigation grids working and the ai basically breaks when I go off the grid or to another grid.
     
  38. chiblue3D

    chiblue3D

    Joined:
    Apr 25, 2012
    Posts:
    19
    I am trying to use this to get the distance from an AI to a point... I want the AI to choose the closest point and move there, the problem is that I want the closest to be based on the path length not the line of sight distance... is there a way using this solution that I can get the length of the path from the AI transform to another transform without moving?