Search Unity

AI [Released] PathBerserker2d - 360° platformer pathfinding

Discussion in 'Tools In Progress' started by PathBerserker2dDev, Jul 14, 2020.

  1. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47

    The Automatic 2D Pathfinding Solution
    Released! Find it here: https://assetstore.unity.com/packages/slug/175968
    YouTuber?
    I will give away free copies in exchange for shout outs. You must have a channel with at least 400 views on your recent videos. Contact me if you are interested. (Any give-aways are up to my discretion, no promises made)

    What is it?

    PathBerserker2d is a new pathfinding solution for 2d platformers.

    No longer do your enemies have to be constrained to the boring “move from left to right and back again” movement pattern seen so often in platformers. Stand out from the crowd with smart enemies, for which even walls and ceilings are fair game to path on.


    Features

    • Full 360° pathfinding. Let your characters walk on walls and ceilings!
    threesixtydegree.gif
    • Supports different agent heights on the same graph!
    heights.gif
    • Supports pathfinding on moving platforms!
    moving_platform.gif
    • Build-in support for elevators, ladders and teleporters!
    elevator.gif
    • Mark areas with custom tags. Tell your agents to avoid/prefer those tags when pathfinding.
    • Bake navigation data at the click of a button from your existing colliders! Automagically!
    • Fully multithreaded pathfinding Find paths with as many threads as you want

    Videos




    Web-GL Demo

    I host a Web-GL demo here:
    https://oribow.github.io/PathBerserker2dDemo/


    Read the Documentation

    I host the documentation that ships with this asset here:
    https://oribow.github.io/PathBerserker2dDemo/Documentation/



    Got any suggestions, ideas for features or need help with the Asset?

    Please comment below!
     
    Last edited: Sep 14, 2020
  2. munchou

    munchou

    Joined:
    Apr 18, 2020
    Posts:
    52
    Hello,
    I'm wondering, when it comes to path-finding, the AI follows a pre-made track, right? Or does it behave according to the surroundings, understanding where it can step and where it would fall to its death?
    Because you wrote "smart enemies", and seeing the last 2 GIF (cute ones, by the way), does that mean that you can "tell" them to go somewhere, and they'll move along their own optimal path while avoiding dying? (like in your third GIF)
     
  3. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Its like a 3d navmesh, but for 2d. The navigation data is prebaked and the agent pathfinds on this data.
     
    Last edited: Jul 25, 2020
  4. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
  5. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Made a new Video to showcase an example setup for the plugin. (Video editing is hard)


    Polishing is going well. It should be ready soon.
     
  6. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Oof. Just finished writing the documentation. I never want to write a documentation again. Its so boring!
    core_concepts_1.png
    (One of the silly graphics I made for the docu.)
     
  7. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Did you know that you can't use
    Gizmos.DrawIcon
    in an asset package?
    The icons for that must be placed in the Gizmos folder. But that folder can't be included in an asset package.

    Thanks Unity! \s
     
  8. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    I'm preparing the final video for the store page. When its completed the submission process can finally begin. Yay!

    Here's a clip for the video. It showcases how PathBerserker2d in combination with user defined markers can produce unique agent behavior. In this example some robots are heat resistant and just go through the lava, others are not and have to take the longer way.

     
  9. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Video completed and it turned out really good! Didn't make it my self, but had help from a cool guy.


    I have submitted the asset to the store now. Hopefully it will be approved soon.
     
  10. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
  11. TheWizardTower

    TheWizardTower

    Joined:
    Jan 26, 2013
    Posts:
    1
    is there a road map?

    real time beking for the nevmesh?
    differnt jump distnaces ?
    wall ditection? (even if i can make it with raycast, having the logic from the path will be nicer)
    edge climb?
    free flying?
    moving platforms in x and y?

    its looking intesrting , and i would want to give it a try, but for now its a bit missing alot. from tutrials + more demos + looking at the docs, everything require payment (there is no refund ) so its 44$ with out seeing what i get.
    and yes, i think there is some features left before making it a full product
     
  12. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Hi there!
    Thanks for the interest, sorry if the features of this asset weren't communicated clear enough.
    Let me go through your questions point by point.

    Is there a road map? - Not yet
    Not yet, but a good suggestion. I'm definitely planning to further develop this asset based on feedback. I wanted to wait for a little more feedback before promising any new features, as I don't want to develop features no one asked for.

    Real time baking for the navmesh? - If there is demand for it
    You can load and unload prebaked navigation data which should cover most use cases. Baking at runtime is possible to implement, but I'd like to know if there is even a demand for such a feature first.

    Different jump distances? - Already there

    JumpLinks can be as long or short as you want them to be. They really are analogous to Unity's OffMeshLinks https://docs.unity3d.com/Manual/class-OffMeshLink.html.

    Wall detection? - Already there
    Right now, you can use the physics system to raycast for an intersection and then ask the pathfinder about what data it has about that intersection. That should be pretty way faster then me rolling my own raycast implementation with all the bells and whistles.

    Edge climb? - Up to you
    This asset is meant to solve pathfinding for a broad range of 2d platformer games. I can't predict in what way edge climbing is going to work in your particular game. The simplest solution would probably be to change the animation of the NPC's when it's following a path on a ceiling to a climbing animation. You could also mark certain edges for climbing and solve it that way.
    So in a sense edge climbing is already supported.

    Free flying? - No and maybe never with this Plugin
    Definitely a neat feature to have, I agree. But the current system only deals with edges. Implementing this would require a completely different pathfinding system that handles the empty space between colliders. That might as well be an entirely new Plugin. Maybe I will do that if there is sufficient interest in it. But it probably will be its own thing.

    moving platforms in x and y? - Already there
    That is already possible.

    from tutorials + more demos + looking at the docs, everything requires payment (there are no refunds) - Going to make Doc available on here
    I guess I could upload the docs to this thread. Thanks for that suggestion!
    I don't quite get what you mean by (there is no refund). All Assets on the Unity AssetStore can be refunded, at least to my knowledge. I'd even personally do so on request.

    Did you play the WebGL demo? If so, what else would you like to see in a demo?
     
    Last edited: Aug 21, 2020
  13. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
  14. brlan10

    brlan10

    Joined:
    Mar 23, 2015
    Posts:
    5
    When I bake my path, it gets offset, as seen below.
    Also, I notice there is a gap on all of the bottom-left corners.
    upload_2020-9-10_12-8-43.png

    When I baked, I received this warning message:
    CreateMesh returned null
    UnityEngine.Debug:LogWarning(Object)
    PathBerserker2d.ColliderConverter:Convert(Collider2D)
    PathBerserker2d.IntersectionTester:ColliderToPolygon(Collider2D)
    PathBerserker2d.NavSurface:StartBakeJob()
    PathBerserker2d.NavSurface2dInspector:OnInspectorGUI()
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)


    I'm kind of in the dark here. The documentation is good, but there is no setup guide so I'm just trying to do my best by looking at the example scenes.
     
    Last edited: Sep 10, 2020
  15. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Hi,

    "CreateMesh returned null" is a message that gets triggered when Unity's CreateMesh returns null. That means a collider could not be transformed into a mesh by unity. What colliders are you using? Edgecolliders are handled differently by the system so that shouldn't cause an issue. The message is just a warning the collider in question will be ignored by the system.

    I've adjusted the warning to be more helpful.

    Thanks for the documentation feedback. I will add a setup section to the next update.

    It would help me a lot if you could post an example scene with the issue occurring. If you do, please PM (or email) me the scene to prevent any accidental leaks of my asset.
     
    Last edited: Sep 11, 2020
  16. brlan10

    brlan10

    Joined:
    Mar 23, 2015
    Posts:
    5
    I am using a composite collider on a Tilemap. I just PM'd you the project.
     
  17. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Okay, I found the bug that caused the offset. CreateMesh acts weird when Rigidbodies are involved, which where used to enable the composite collider. I fixed that now.

    The warning also was given because of the composite collider. A composite collider can't be turned into a mesh and it also shouldn't be. I will change the system to ignore composite colliders.

    As for the gaps, I've drawn an image to illustrate why this is happening. In your case I suggest to switch the collider type of your tiles from "Sprite" to "grid".
    overhang_problem.png
     
  18. smiker

    smiker

    Joined:
    Apr 7, 2013
    Posts:
    9
    hello,

    first of all, great work with this asset. I'm trying to use it in my project but I have a problem with segment slopes. I will attach an image for explanation.
    PathProblem.png
    Could you tell me where is the problem? I don't know why the agent don't go to the red point. If I move the red point left of the agent, it works well.

    Thank you.
     
  19. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Interesting. Could you make an image of your collider setup? Or better yet send me that scene in a pm? I can't tell from the image alone what issue might be.

    I would guess, that the slope's green line doesn't connect with the horizontal green lines. This might be an issue with the collider setup.
     
  20. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Thanks, I identified the problem.
    single_point.png
    The colliders meet at a single point (encircled by red). This can either lead to the creation of one polygon containing all (what you would want), or of 3 seperate polygons (marked in yellow), which is what caused the wierd behaviour.

    Such single point touching of colliders should always be avoided.

    I suggest you add a filler tile to make it a real hull.

    hull.png
    The yellow hull now definitely is one polygon, instead of being multiple. That filler tile does not need to have a texture. It can be entirely invisible to the player, but it must be set to have a collider.

    This explanation is definitely something I will add to the documentation of the next release as it isn't immediately obvious.
     
  21. smiker

    smiker

    Joined:
    Apr 7, 2013
    Posts:
    9
    Thank you for reply, I will try your solution.
     
  22. smiker

    smiker

    Joined:
    Apr 7, 2013
    Posts:
    9
    Hello, your solution works perfectly! Now I have another little problem... There was an option to disable rotation on corners? I don't need the rotation on stairs in some agents.

    May be the solution are to put a link on corners??
     
  23. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Just remove the AdjustRotation script from your NavAgent. Its what adjustes the NavAgents rotation to be perpendicular to the current segment normal.
     
  24. smiker

    smiker

    Joined:
    Apr 7, 2013
    Posts:
    9
    That was my first try with no luck, only works when I insert links on corners.
     
  25. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Okay. Sorry that was an oversight of mine. In the next release I'll add a checkbox on the NavAgent to control corner rotation. For now, you can just attach this script to the NavAgent and the rotation should stop.

    Code (CSharp):
    1. using PathBerserker2d;
    2. using UnityEngine;
    3.  
    4. public class CornerRotationSkipper : MonoBehaviour
    5. {
    6.     [SerializeField]
    7.     NavAgent agent;
    8.  
    9.     void Start()
    10.     {
    11.         agent.OnStartLinkTraversal += Agent_OnStartLinkTraversal;
    12.     }
    13.  
    14.     private void Agent_OnStartLinkTraversal(NavAgent agent)
    15.     {
    16.         if (agent.CurrentLinkType == "corner")
    17.             agent.CompleteLinkTraversal();
    18.     }
    19. }
     
  26. smiker

    smiker

    Joined:
    Apr 7, 2013
    Posts:
    9
    Thank you, it works.
     
  27. BonAppetit92

    BonAppetit92

    Joined:
    Jun 15, 2017
    Posts:
    6
    Hi, just got the pathfinding asset and it works. Thanks a lot!
    I am wondering is there an agent width parameter like the navmesh in 3D?
    Besides, any solution for the flying agent in current version?
     
  28. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    There is no width parameter. The pathfing system models a NavAgent as a walking stick. This was a design decision I made, because width in 2d games can be interpreted in different ways. For example, slopes may require an agent to clip into the ground or rotated to align with the ground. A width check would not allow such a character to enter a slope.

    Flying agents are not currently supported. Flying requires different pathfinding data and algorithms. It wouldn't be an addition to the current system, but an almost completely new and different system. I need to evaluated whetever this would be worth the developement time.
     
  29. BonAppetit92

    BonAppetit92

    Joined:
    Jun 15, 2017
    Posts:
    6
    Thanks for your reply!

    In the case of agent width, is there a possible feature update to make us able to shorten the length of the final segment when it is not close? This could in some sense solve the agent width problem without affecting the slope mechanics i think. And also different agent could use different pre-baked path which would give a limited degree of freedom in designing the agent's width.
    upload_2021-1-2_12-5-29.png

    For the flying agent, I guess current solution is turn to the traditional 2d top-down pathfinding method. Since it is already included in many pathfinding asset, would you still consider to add this function if there are demand? Really hope your pathfinding asset could be "the" asset for all 2d platform game.
     
  30. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Do you mean, update the check for if the agent reached is goal, to consider an agents width?

    Yeah, I'd like to do that.
     
  31. smiker

    smiker

    Joined:
    Apr 7, 2013
    Posts:
    9
    Hello, I updated to the last version, added the new "transform base movement" component but my NavAgents not move.

    I debug the NavAgent and have the HasValidPosition to false and "currentMappedPosition.surface" to null. I think thats the reason of the problem by I don't know why this happend after update.

    Best regards.

    More information:
    I make a simple tile map to explain the problem.
    In first image the cube to the left don't walk to the image of the right.


    In the second image, I have erased the ceiling, rebaked and works perfect.


    The cube height was 0.1, I was tray with 1 and 2.

    Any idea what I'm making wrong?

    Again... more information. it works if I make a wall... You could see in the las image.

     

    Attached Files:

    • Fail.png
      Fail.png
      File size:
      23.9 KB
      Views:
      335
    • OK.png
      OK.png
      File size:
      20.4 KB
      Views:
      327
    • Final.png
      Final.png
      File size:
      40.1 KB
      Views:
      331
    Last edited: Jan 7, 2021
  32. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    I'm very sorry you experience this issue. There is a bug-fix coming in the next update that should hopefully fix your problem. The update is already submitted and should be live in 1-2 days. (Depends on Unity really)

    If you like to get it earlier, write me a PM with invoice number and I'll send it to you early.
     
  33. smiker

    smiker

    Joined:
    Apr 7, 2013
    Posts:
    9
    Ok, thank you, I could wait until release.
     
  34. BonAppetit92

    BonAppetit92

    Joined:
    Jun 15, 2017
    Posts:
    6
    Hello!
    I am currently using two navsurface components attached to two different composite colliders (one for solid platform and one for one way platform). However, when i place a random walk agent to the scene, it seems that it could only move along either the solid platform surface or the one-way platform surface.
    Instead of adding links to the adjacent points, is there any other way in combining the two tpyes of navsurface?

    upload_2021-1-18_3-33-38.png
     
  35. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Sorry, that is not possible. Internally segments in a NavSurface are represented as a quasi linked list. Branching is not possible. Every segment can only connect to two other segments at each of its end points.

    You have to use links to connect them. There is no otherway. Internally, the connection between two segments is modeled as a link anyway. A link of type "corner" to be exact.

    You probably don't want your agent traversing this link by jumping right? You can set the link type to "teleport" and the agent won't jump. If the link points are close enough the teleportation won't be visible.
     
  36. BonAppetit92

    BonAppetit92

    Joined:
    Jun 15, 2017
    Posts:
    6
    Hi, here is a bug report related to the TransformBasedMovment class.
    Following is an example, it seems that part of the code failed in moving platform situation, which lead to abnormal agent motion when jumping outside a moving platform (I guess vice versa since direction * timeOnLink * jumpSpeed doesn't consider the moving end point)
    upload_2021-1-19_2-24-59.png
     
  37. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    You are right. Good catch!
    agent.CurrentLinkStart indeed changes with a moving platform. I'm going to add your idea of storing the link start in a variable to keep it constant.

    I'm wondering if I should also make the jump react to a moving goal position. Right now, an Agent can miss a jump, if the goal moves to much. But making a jump always land on its target no matter how fast it moves, can make the jump look reality bending wierd. Thoughts?
     
  38. BonAppetit92

    BonAppetit92

    Joined:
    Jun 15, 2017
    Posts:
    6
    Since to achieve moving goal position requires the prediction of moving path and set the agent jump in advance, finding a sophisticate solution requires a lot of extra work besides the path finding method itself. Currently, i am adding restrictions on the validation of the jump link and making the agent jump in the frame of moving goal. Although this kind of tricks aren't really solve the question itself but for me it works and acceptable.

    For the restriction of in the jump link, in current version, the length of the link seems to be the only condition to check whether this edge is valid in the graph of path finding. What i am doing is adding an ITraversable interface to the moving platform and make it communicate with the navlink when the moving platform becomes the goal of the jump. The platform becomes traversable when the motion of it is under certain condition (I set stoped in my project). I think it is also good to add similar interface to your asset since it give extra control of the nav link and no extra work for you to decide when the moving goal is traversable.
    upload_2021-1-19_14-11-11.png

    Last, I really wish you could add a component that could combine all the navsurfaces under its child objects. (raised in my previous post) Adding a tiny navlink to every navsurfaces addjacent point is really frustrated. If two segement from different navsurface are close to each other, just make me able to set them linked automaticly plz.
     
  39. EwertonBR

    EwertonBR

    Joined:
    Feb 7, 2018
    Posts:
    18
    Works only with tiles? or I can use it without a grid?
     
  40. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Works with every 2d collider. I guess I gotta add some non-tilemap screenshots to the storefront :D.
     
  41. templewulf

    templewulf

    Joined:
    Dec 29, 2013
    Posts:
    52
    @PathBerserker2dDev I picked this up this week, and I really love a lot of what you're doing in this asset. I almost even considered changing my 2d game to 2.5d to shoehorn in Unity's NavMesh system into my platformer until I saw this one!

    I have one main question and a couple of side questions.

    #1: I'm getting the error "Agent couldn't be mapped to a NavSurface. Pathfinding won't start. An agent must be above and close to a surface to map." from NavAgentInspector.cs:164. I can see that it has something to do with navAgent.currentMappedPosition.surface being null. How do I approach troubleshooting this?

    I can see:
    • The bottom of my agent's collider is at -3.54, and the top of my ground collider is -3.6. Even if I turn on gravity and drop it directly onto the ground, the error remains.
    • I have the purple outline displaying correctly from the bake.
    • My agent has the Goal Walker, TransformBasedMovement, and NavAgent components
    • All of my NavAgent settings are defaults, except Enable Debug Messages (true) and Max Slope Angle (75)
    #2: The TransformBasedMovement component seems to require CornerLinks enabled if I want my Agent to be able to follow JumpLinks. When CornerLinks are disabled, the agent just stops at the first JumpLink with an AgentState of FollowPath. Is this intentional? Is it explained anywhere that JumpLinks require CornerLinks?

    #3: What approach do you recommend for receiving events from the NavAgent or TransformBasedMovement for things like animations? Should I subclass TransformBasedMovement?

    Thanks!
     
  42. templewulf

    templewulf

    Joined:
    Dec 29, 2013
    Posts:
    52
    Oh, wait, I think I figured out #1. It seems like the line segment detection is coming from the sprite's pivot point, not the bottom of the collider. So if I have a sprite whose pivot is in its center of mass instead of its feet, it can never hook into the navsurface, because its collider will always keep it too far away.

    Any suggestions?
     
  43. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    #1: Like you already found out, the segment detection is coming from the sprite's pivot point. You could either adjust the collider's offset.
    upload_2021-4-30_17-58-24.png
    Or move the collider to a child GameObject and move that.

    #2:
    Thanks for bringing that up. This is not intentional and is going to be fixed.

    #3:
    So the NavAgent has a events that you could subscribe to and play the appropriate animations. Something like OnSegmentTraversal to play a walking animation and OnLinkTraversal to play jumping animations. You can also always poll the current NavAgent state.

    Subclassing TransformBasedMovement won't do you much good as its not really designed to be subclassed. (lots of private methods, not protected) If you want to go in that direction, I'd recommend writing your own movement script with animations. You can use TransformBasedMovement's code as base and then rewrite it as you see fit in your own movement handler.
     
    templewulf likes this.
  44. GiomGots

    GiomGots

    Joined:
    Apr 3, 2021
    Posts:
    13
    Hi,

    I'm considering thye purchase of your package, but i'd like to know two things:
    Can you use it on mobiles games ? How is it performance-side ?
    In my game the player is editing a tilemap, deleting tiles and adding new ones, how your package will handle that ? Is it possible to re-trigger a scan ?

    Thanks, cheers !
     
    Last edited: May 5, 2021
  45. PathBerserker2dDev

    PathBerserker2dDev

    Joined:
    Jul 14, 2020
    Posts:
    47
    Hi,

    I'm sorry, but I can't say much about its usage on mobile. I've never tried it. It shouldn't be a problem really.
    Its performance is pretty good and the pathfinding stuff is threaded.

    Here is a profiler screenshot of one of the example scenes with 8 NavAgents moving around randomly.
    upload_2021-5-5_21-49-53.png

    For your second question, it is possible to trigger a rescan (I call it baking) at runtime. This also happens in a separate thread, so it won't stall the actual gameplay.
    You do have to figure out a way to place NavLinks (jumping, climbing, ...) yourself though.

    If you have anymore questions, I'm happy to answer them. :)
     
    templewulf and GiomGots like this.
  46. GiomGots

    GiomGots

    Joined:
    Apr 3, 2021
    Posts:
    13
    Thanks for the answer, it's appreciated :)
     
  47. GiomGots

    GiomGots

    Joined:
    Apr 3, 2021
    Posts:
    13
    Hi,

    I bought it !
    I integrated it in my project and here i go with the rebake function when it's built for android, i get this error

    upload_2021-5-6_18-35-57.png

    It works like a charm when I test on unity editor of course
    Any idea ?

    Thanks :)
     
  48. templewulf

    templewulf

    Joined:
    Dec 29, 2013
    Posts:
    52
    Thanks for your earlier help! I've been progressing smoothly. I hit one snag, though. What's the workflow for introducing obstacles whose colliders should inform the NavSurface not to create a line segment when baking?

    For example, consider Mario games with flat surfaces, dotted with spikes or other single-tile-sized hazards. Essentially, I want to break the bottom line segment in this picture to force my nav agents to use the jumps
     

    Attached Files:

  49. viajefest

    viajefest

    Joined:
    Mar 7, 2021
    Posts:
    1
    I’ve been playing around with your script and I think its pretty awesome, I see a lot of potential on my project, but I have been facing some trouble, perhaps you can help me understanding some stuff.

    -I would like to print in the console the NavAgent.State, however it keeps trowing this message:

    error CS1061: 'NavAgent' does not contain a definition for 'NavAgent' and no accessible extension method 'NavAgent' accepting a first argument of type 'NavAgent' could be found (are you missing a using directive or an assembly reference?)

    This is what Im trying:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using PathBerserker2d;
    5. public class PlayerAI : MonoBehaviour
    6. {
    7.     [SerializeField]
    8.     private GameObject followObject = null;
    9.     private NavAgent followNavAgent;
    10.     private void Awake()
    11.     {
    12.         followNavAgent = followObject.GetComponent<NavAgent>();
    13.     }
    14.     // Update is called once per frame
    15.     void Update()
    16.     {
    17.         print(followNavAgent.State);
    18.     }
    19. }
    This is probably very easy, however since im pretty new to Unity and C# I don’t have a clue of what Im doing wrong.

    By accesing to the NavAgent.State this is what I want to achieve:
    Code (CSharp):
    1. If( !followNavAgent.State.isIdle)
    2. {
    3.     //Set some values to other object
    4. }
    5. else{
    6.     //reset the values
    7. }
    Hope you can give me a hand. Thanks a lot.
     
    Last edited: May 15, 2021
  50. GiomGots

    GiomGots

    Joined:
    Apr 3, 2021
    Posts:
    13
    Hi,
    You doing good man ? (or woman)

    Came here for news becaue i can't currently use what i bought in my project...
    Any news on that topic ?

    Cheers