|
Post by redsam121 on Apr 24, 2023 11:40:52 GMT
I'm trying to integrate the navmesh components such as navmesh surface, to allow more dynamic movement for AI (e.g. walk onto platforms), but I've run into a number of problems.
- There is a delay for when the AI recalculates paths.
- The Navmeshagent ignores the navmesh surface boundaries and walks off the edge.
Can someone help me solve these problems, so I can create a new integration.
|
|
|
Post by redsam121 on May 2, 2023 12:00:05 GMT
This is an example of what I'm trying to accomplish for the AI movement.
|
|
|
Post by redsam121 on May 2, 2023 15:42:58 GMT
I have made a prototype for the jump mechanics so that the AI is compatible with NavmeshLink. Though still haven't solved the first two problems.
public virtual bool isOnJumpLink { get { if (!useNavMeshAgent) return false; if (navMeshAgent.isOnOffMeshLink && navMeshAgent.currentOffMeshLinkData.linkType == UnityEngine.AI.OffMeshLinkType.LinkTypeJumpAcross) return true; var linkData = navMeshAgent.currentOffMeshLinkData.offMeshLink; if (linkData != null) { if (linkData.area == UnityEngine.AI.NavMesh.GetAreaFromName("Jump")) { return true; } } if (navMeshAgent.navMeshOwner is NavMeshLink) { var linkData2 = (NavMeshLink)navMeshAgent.navMeshOwner; if (linkData2.area == UnityEngine.AI.NavMesh.GetAreaFromName("Jump")) { return true; } } return false; } }
|
|
|
Post by redsam121 on May 3, 2023 4:48:33 GMT
I solved the second problem by increasing the stopping distance, so now I only have the recalculate path problem left.
|
|
|
Post by redsam121 on May 3, 2023 9:30:23 GMT
I have create a prototype code for recalculating paths when current is only partial. When a new path is available it will update the current path.
//If path is incomplete find a new path if (navMeshAgent.path.status == NavMeshPathStatus.PathPartial) { NavMeshPath newPath = new NavMeshPath(); navMeshAgent.CalculatePath(_destination, newPath); Debug.Log(newPath.corners[newPath.corners.Length - 1] != navMeshAgent.destination); //Only update path when a new closest destination is available if (newPath.corners[newPath.corners.Length - 1] != navMeshAgent.destination) { navMeshAgent.ResetPath(); } }
|
|