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

To the coder of Navigation, sugestions!

Discussion in 'Navigation' started by Miscellaneous, Mar 17, 2019.

  1. Miscellaneous

    Miscellaneous

    Joined:
    Sep 24, 2013
    Posts:
    53
    I desire to swipe a path for NavMeshAgent to follow (which also respect the walkplate)

    Just one of the following suggestions (Vector3[] to NavMeshPath) below will open up possibilities! (In my case waypoints have already been checked against areaMask, so all points are valid)

    NavMesh.CalculatePath( Vector3[] waypoints, int areaMask, AI.NavMeshPath path);
    * Being able to give an array of Vector3[] waypoints to calculate the out NavMeshPath

    NavMeshPath.corners = Vector3[] waypoints;
    * Being able to set an array of Vector3[] waypoints as corners.

    NavMeshPath.corners.Length = int i;

    * Being able to set numbers of corners, useful with NavMeshPath.corners[ i ].Set( x,y,z );

    How to reach the programmer(s) behind Unity? in this case Navigation...

    p.s. using Unity 2017.4.23f1
     
    Last edited: Mar 18, 2019
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Why not just make a patrol component that sets each waypoint as destination in a sequence, handing over the next waypoint as soon as the agent has reached the current waypoint?
     
  3. Miscellaneous

    Miscellaneous

    Joined:
    Sep 24, 2013
    Posts:
    53
    Are you for real? All is their by default, just the technology have been locked down, wouldn't it be better to have stuff functional beyond whatever restrains the creator(s) are bound by?
     
  4. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Because what you're trying to do here is not generic enough for a core component. Waypoint navigation is common, but far from the only reason why you'd want to use the NavMesh system. Not only that, but by simply adding a "brain" to the system via composition you can easily do what you're trying to do here yourself, and have very fine control over it.
    However, baking in these extra features might interfere with other functionality of the agent. We don't have the source code, so we don't exactly know what horrors Unity is keeping beneath the surface.

    I mean, sure, it would be absolutely amazing if an engine has each and every feature tailor-made to what you exactly need in your game, but that engine would be absolutely terrible as a 3rd party engine trying to power many different kinds of games. There are very light-weight solutions to what you're requesting here you can build yourself with minimal coding. Just roll up your sleeves.
     
    DwinTeimlon and adriant like this.
  5. Miscellaneous

    Miscellaneous

    Joined:
    Sep 24, 2013
    Posts:
    53
    Are you from Unity? I mean can you make the call what is not generic enough for a core component? Isn't the whole idea about technologies to be able to use them all together, flexible?

    You make it sound like its a big task "baking in these extra features might interfere with other functionality of the agent", the agent operates on a given path, if your path count is e.g 10 waypoints, you can manual adjust those waypoints with path.corners[ i ].Set( x, y, z ), so their shouldn't be anything breaking the Agent, agree? The problem here is you have no way of setting the count yourself.

    Sorry, Yandalf, I don't understand you, are you here too ensure Unity doesn't improve? Isn't it in the community best interest to help Unity improve their technologies? Of cause if you tell me, the programmer(s) of Navigation have left the company and no one at Unity have interested in looking into her/his code, then your response makes sense :)
     
  6. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    I'm not with Unity and can't make those calls, no.
    However, what you're proposing here can very easily lead to people setting corners for the path that the agent actually can't linearly move between unless the agent would, behind the scenes, check everything again and possibly end up with different results anyway. At that point you should be asking yourself what the point even is.

    For example, say you set 2 corners (the absolute minimum required) which actually have a wall between them that your agent needs to navigate around. Either the agent will just take what you give it at face value and slam head-first into the wall which is hardly idiot-proof, or it will check the navmesh and construct a path accordingly at which point you're basically just calling SetDestination in a VERY roundabout way.

    I'm not here to do anything beyond help people, I'm just not understanding what the point of your API proposals even is.
    Your first proposal is basically just something most people would throw in an extension method and call it a day, whereas the other two from my understanding would actively make the component more prone to error.
    But hey, who knows, the guys at Unity do know better than me how this system works and they might actually see value in it. If you want their attention though, the Navigation forum isn't the place.
    Your best bet might be the NavMeshComponent github, which seems to be the new direction they want to take the NavMesh system in to (although there's talks about a completely new system compatible with ECS as well).
     
  7. Miscellaneous

    Miscellaneous

    Joined:
    Sep 24, 2013
    Posts:
    53
    Didn't I mention above "(In my case waypoints have already been checked against areaMask, so all points are valid)", I mean, in between every swipe I check against path-finding... When operating at this level, you should know what you doing, and since path.corners[ 0 ].Set( x, y, z ) isn't documented, so I assume its for that reason alone, but being able to modify the content of the Vector3 Array, but not being able to set the Length is the question.

    Building a higher level way-point system will make a performances impact, beside out of sync stuff with those elements using the NavMeshAgent.
     
  8. adriant

    adriant

    Unity Technologies

    Joined:
    Nov 1, 2016
    Posts:
    68
    What @Yandalf is proposing is reasonable and it's maybe the only solution that Unity can currently offer for this kind of situation, when you'd want the agent to follow a path going through multiple waypoints.

    Having a method like NavMesh.CalculatePath( Vector3[] waypoints, int areaMask, AI.NavMeshPath path); is also a reasonable request, it could be implemented, but I can tell you that it doesn't justify the implementation cost currently when the aforementioned generic approach exists.

    path.corners consists of read-only data because those points are computed from the internal structures that define the valid path to the destination. It's only a one-way conversion. The agent doesn't use these corners; it uses the internal path information directly to move forward. The path must be reliable and can only be modified by setting a destination on the agent or by setting a path computed with CalculatePath().
     
  9. Miscellaneous

    Miscellaneous

    Joined:
    Sep 24, 2013
    Posts:
    53
    What really baffled me, is the your already implemented function path.corners[ i ].Set( x, y, z ) where you are able to adjust way-points of an already "read-only" calculated path, but not being able to adjust the Length of that path. It seems like almost all code needed is already done and with a minimum effort from Unity we can have more flexible ways to use NavMeshPath with aka touch swipe...

    I mention 3 solutions, but only one is required to work (admitting the order of presenting was from hardest to easiest to implement)
     
    Last edited: Mar 19, 2019
  10. adriant

    adriant

    Unity Technologies

    Joined:
    Nov 1, 2016
    Posts:
    68
    path.corners gives you an array of Vector3 points. It's yours from that point on, to do whatever you want with it. You can freely modify any of the values in that array, but none of those changes get propagated back to the navigation system in any way. The agent will not follow the modified corners. Thus the solution you speak of cannot be achieved. Only by modifying the CalculatePath() method we could customize the agent's path and ultimately the corners.
     
    joshcamas likes this.
  11. Miscellaneous

    Miscellaneous

    Joined:
    Sep 24, 2013
    Posts:
    53
    Then I keep my fingers crossed and hoping for the day an Unity engineer get struck by an irresistible desire to implement NavMesh.CalculatePath( Vector3[] waypoints, AI.NavMeshPath path);