Use Unity3D NavMeshAgent.Move to customize your navigation control

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
it was adjacent here from unity3d college in this video I just want to show you a little trick with the Unity navigation system that might help you with a problem that you've run into certainly one that I've run into where the characters going to move in an odd direction so like I don't want these guys spinning like this if you look right there I'm going to show it one more time watch this character you'll see that when I just use the nav mesh agent and set the path set the differe set the destination he does that kind of spin around and slide and really what I wanted to do is go forward and the one I'm just going to move along like an actual skater would I think there are other lot of other cases where you want to have the character move and have a tiny bit more control okay so what I've got here is a just a clasp on here that controls the navigation system and is the default way to do it would be just to set the nav mesh agents destination right here so just call a nav mesh agent set destination and pass in the point that we want to move to so what I want to show you though is a way where we can use this this nav mesh agent move and actually control it ourselves so if you look here in the update method before I wasn't doing any movement these were commented out so nothing was actually happening here other than some pointless calculation that's just so you can see what it looked like the other way here what I'm going to do is slowly turn the character towards the destination based off of how far away they are and how far behind them it is if it's right behind a mower and return a lot faster and move slower if it's further away and they can make the turn in skate over there they'll do a booster turn so I do that with this look toward method the details of it don't really matter and then the speed modifiers again just they slow down as they get closer to things if they need to make a tighter turn or they're about to stop at the point what I want to point out though is this right here this nav mesh agent not move this doesn't let you pass in a movement kind of like you would on a character controller except in here it won't go off the nav mesh agent oversee off the navmesh so if I play like this let me make sure I save so it actually works now when I play should see the character just going to move along and just to be clear I'm not sure using a nav meshes ideal for this game which is something I kind of wanted to try out so there we go he shoots and then you kind of skates around you can see he turns does an actual attorney doesn't slide backwards and sideways and then just to demonstrate this one more time in a little bit emptier fashion I show you this nice little empty project so you can get that lined up right there we go so here I've just got a nav mesh right here on this cube if I go to there you can see there's the nav mesh this capsule is just an agent with a single script this nav mesh mover script which just calls move forward times time.deltatime just going to move the thing straight along and what you see is you know it'll move forward like character controller would or moving the transform would but it won't go off the navmesh so it lets you keep those constraints Rossdale getting some extra control over the character so I just thought it was kind of a cool little feature and something that I didn't see anything written about other than a little note on the official documentation so I figured I'd share it and hopefully it helps you out somehow if you like that don't forget to hit like and subscribe thanks for watching
Info
Channel: Jason Weimann
Views: 60,368
Rating: undefined out of 5
Keywords: Unity3D Navmesh, Unity3d Navmeshagent, Unity3D NavMeshAgent.Move, Unity3d Navigation, Unity3D Nav, Customize Unity Navigation
Id: SV1eE1hvuqY
Channel Id: undefined
Length: 3min 56sec (236 seconds)
Published: Wed Aug 16 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.