I’ve been testing Nav Mesh Agent and i really like it because of it’s auto route system, but i can’t get a good movement system with it.
I’ve tried a lot of values but i can’t get a responsive movement for it, Specially when i set a new position while it’s moving, doing some kind of ice skating and drifting to the next destination.
I would like to Instantly turn the navigator to the new directlion i clicked the character to move to (It’s a click and move game), But i can’t manage that by changing values in the inspector.
Do i have to do a code just to achieve that or is it a proper way to do so?
Best approach would probably be, is to write your own little method to turn your object towards NavAgent’s first turn point.
First use NavAgent to calculate the path and then use the path’s waypoints to determine where your object should turn, after your turning method send the agent on its way.
You can always turn the rotation speed of the navmeshagent way up: the faster this is, the faster it rotates towards destination. This combined with turning acceleration down a bit might be a simple way to solve this problem. if the acceleration is low, it will take longer for the object to get moving, this was how I personally fixed the issue.
With regards to animation, you might want to make a check that the object is moving a certain speed (check the vector3.distance(newpos, oldpos) ) before playing something like a walking animation. Maybe something like:
I’m still trying to figure out a way to find which absolute direction the navmeshagent is rotating in. Hard because when it rotates 360 degrees it switches from negative to positive, visa versa.