What the system is. Definition of problem.
I am developing a mobile game without using physics (except for trigger volumes). The player moves purely on a navmesh, using Unity’s built-in navmesh and NavmeshAgents. The player has an on-screen joystick, and so movement is done every Update() rather than in a click-to-move style. The fact that I must update the player’s heading every Update() tick seems to be part of my problem in creating a Player character which is able to smoothly collide with obstacles and other navmesh agents.
Previous Research
I read a great thread:
http://forum.unity3d.com/threads/130012-Need-Advice-or-Recommendations-with-NavMesh-and-Agents
In which AngryAnt so helpfully explains a good way to implement movement in such a system. As we build our game, I have used (kind of) his approach, and also another approach of just using SetDestination(pos). Each approach seems to have its own flaws, and I cannot seem to find a perfect, smooth solution.
Approach #1 flaws
When using the (kind of) approach suggested by AngryAnt (IE: Calling .Move(pos)), The overall movement of the agent is very jittery (but no rubber-banding). I have the script setup with: navAgent.updatePosition = true;
Approach #2 flaws
When using the more simplistic .SetDestination approach, I get rubber-banding under certain conditions (the conditions are not clear to me, but mostly the rubberbanding only happens when the system is under heavy load, like when I am running full-screen image capture at the same time as simulating the game in Unity).
Approach #3 flaws
I expanded the 2nd approach to use the NavMesh’s raycast function to try to resolve the rubberbanding. I thought that perhaps the rubberbanding was due to trying to set a destination outside the navmesh bounds. However, making sure that my .SetDestination() calls always pointed to a position on the navmesh did not resolve the problem.
Summary
I have tried the above 3 approaches with various different sets of NavMeshAgent script settings, like enabling or disabling AutoBraking or AutoRepath and so forth. AutoBraking seems to have the biggest impact, but since Unity’s NavMeshAgent code is not visible, I really cannot tell what Unity is doing behind the scenes with all those attributes, and it does not appear that the NavMesh or NavMeshAgent scripts expose any way to detect other agents or obstacles, so I must rely on the NavMeshAgent script itself to update my character’s position, which makes all those attributes still quite relevant (even though in reality they are irrelevant, since I am not trying to do pathfinding)
If anyone has any insight into how to properly set this up (again, not using physics, using a joystick to move, no jitter, no rubber-banding, colliding with other Agents + Obstacles, and also preferably sliding around obstacles), I greatly appreciate it.
If the answer to this inquiry is that I must track all NavMeshAgents and NavMeshObstacles myself, and raycast against the navmesh, etc. (effectively duplicating the NavMeshAgent script, minus pathfinding), then I will, but I want to be sure I haven’t missed something first.
Thanks!