Search Unity

[RELEASED] Turbo Timeline Tools - NavMesh Enhanced

Discussion in 'Assets and Asset Store' started by Drowning-Monkeys, Jul 21, 2020.

  1. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    Hi Guys,

    I'm working on a series of tools for timeline that I call "Turbo Timeline Tools" (because nothing is cooler than alliteration).

    Today we dropped our first tool: "NavMesh Enhanced". The key purpose for this tool is to help you see your Navmesh Agent walking from point A to point B in the timeline, something that the current unity timeline tool does not do.

    Key features:
    1. Editor & Playmode scrubbing of navmesh based movement
    2. Live recalculate during scrubbing (like if an obstacle obstructs the path)
    3. Debug Raycast showing the path
    4. Works with Animator controllers or the Animation track



    You can grab it here:
    https://assetstore.unity.com/packages/tools/animation/turbo-timeline-tools-navmesh-enhanced-173816

    And obviously, feel free to ask questions and report bugs here!
     
  2. SorraTheOrc

    SorraTheOrc

    Joined:
    Jun 11, 2016
    Posts:
    209
    I was just about to start writing some improved Timeline Navmesh tools. Grabbing this instead, it looks great. If you don't hear from me assume I'm happy, if you do I hope it will be with constructive feedback but if need be I'll bring you bug reports.
     
  3. SorraTheOrc

    SorraTheOrc

    Joined:
    Jun 11, 2016
    Posts:
    209
    Well, it didn't take me long to find the first bit of constructive feedback... you are importing some of the Standard Assets. These are horribly broken (at least for 2019+)

    upload_2020-7-26_11-42-24.png

    You really need to remove this from your pack. I assume you are using it in a demo scene (I've not checked). I recommend only importing the animations and use a different controller that doesn't give errors. Do you use the controller to translate the NavMesh movement to animation controller? If so I have a really simple, but effective one for this purpose. It's under a permissive open source license so you can safely use it in your asset, see https://github.com/TheWizardsCode/Animation/blob/master/Assets/Scripts/SimpleLocomotionController.cs

    I've deleted the Standard Assets and the error has gone (it's trivial to fix too, but I want to get on with testing ;-)
     
  4. SorraTheOrc

    SorraTheOrc

    Joined:
    Jun 11, 2016
    Posts:
    209
    OK, this time it's a potential bug. I've set the scene up with just a plane, added a navmesh and have an UMA character with the NavMesh Agent. I have two "marks" at 0,0,-10 and 0,0,0. I've added the track and placed a NavMesh clip with the two marks at the start of the clip. I get the following error. I'm debugging now.

    ```
    NullReferenceException: Object reference not set to an instance of an object
    TTTNavmeshEnhanced_PlayableBehaviour.PathDistance (UnityEngine.Vector3[] _path) (at Assets/Turbo Timeline Tools/Navmesh Enhanced/TTTNavmeshEnhanced_PlayableBehaviour.cs:292)
    TTTNavmeshEnhanced_PlayableBehaviour.InitalSetUp (UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) (at Assets/Turbo Timeline Tools/Navmesh Enhanced/TTTNavmeshEnhanced_PlayableBehaviour.cs:148)
    TTTNavmeshEnhanced_PlayableBehaviour.OnBehaviourPlay (UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) (at Assets/Turbo Timeline Tools/Navmesh Enhanced/TTTNavmeshEnhanced_PlayableBehaviour.cs:78)
    ```
     
  5. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    @fgardler Hey man thanks for purchasing the tool. Let me read over these today and I'll respond tomorrow
     
  6. SorraTheOrc

    SorraTheOrc

    Joined:
    Jun 11, 2016
    Posts:
    209
    I think the problem is in `UpdatePath(Vector3 startPos, Vector3 endPos, bool _forwardInTime, Vector3[] lastPath, bool _recalculate = false)` When at the start of a timeline. It is returning a null array for `pathArrayPast` in the `InitalSetUp(Playable playable, FrameData info)` method.
     
  7. SorraTheOrc

    SorraTheOrc

    Joined:
    Jun 11, 2016
    Posts:
    209
    The previous message is what happens when the playhead is at the start of a path. The original error also occurs when the playhead moves. The problem is still in the same `UpdatePath` method returning a null for path past. But in this case the calling method is `public override void PrepareFrame(Playable playable, FrameData info)`
     
  8. SorraTheOrc

    SorraTheOrc

    Joined:
    Jun 11, 2016
    Posts:
    209
    Here's your problem:

    `lastPathArrayPast` is not being initialized, this results in a null being past into UpdatePath(Vector3 startPos, Vector3 endPos, bool _forwardInTime, Vector3[] lastPath, bool _recalculate = false). So when defaulting to the last position because `canCalculatePath` is false it returns a null.

    Still looking into a) why I'm not calculating a path (may well be bad configuration on my part) and b) how to prevent the null pointer in this situation.
     
  9. SorraTheOrc

    SorraTheOrc

    Joined:
    Jun 11, 2016
    Posts:
    209
    OK. Confirmed, as expected, that it can't find a path because I need a coffee :)

    So this is an edge case bug caused by user error. This circumstance, however, could easily be found in a game so I recommend guarding against it. My quick and dirty method is simple to add an if (lastPath == null) lastPath = new Vector3[0]; at the start of the UpdatePath method. This stops the error, but of course the agent doesn't move, so it should probable emit a warning too.

    I now have my character moving but it's not working well, lots of jitter. Might be me though, as we've seen. Will report back (hopefully not many times in an hour!)
     
  10. SorraTheOrc

    SorraTheOrc

    Joined:
    Jun 11, 2016
    Posts:
    209
    OUCH! You are disabling all the components on the NavMesh agent during initial setup and then reenabling them in Pause and Stop. This completely breaks any object that has any kind of initialization code when enabled, or that should carry on running because, you know it's essential to the object. A really simple example would be an AudioSource.

    I assume you are doing this for a good reason, but it makes your asset unusable in anything but the most simple of cases. What is the reason for this choice? Perhaps we can work out a better way.
     
    Alic and _slash_ like this.
  11. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    alrighty. Yeah I left something (in regards to standard assets) in there so people could test, but you're right.
     
  12. ddplay

    ddplay

    Joined:
    May 14, 2019
    Posts:
    3
    • Lots of bugs, why didn't the author fix them