Skip to content

Commit

Permalink
Merge pull request #1 from Ali-RS/Fix3DPathfind
Browse files Browse the repository at this point in the history
Consider cell heights when finding path
  • Loading branch information
MeFisto94 authored Nov 15, 2016
2 parents 80e04ca + c81e15a commit e510a6f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions AI/src/com/jme3/ai/navmesh/NavMeshPathfinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,14 @@ public boolean computePath(Vector3f goal) {
*/
public boolean computePath(Vector3f goal, DebugInfo debugInfo) {
// get the cell that this point is in
Vector3f newPos2d = new Vector3f(currentPos3d.x, 0, currentPos3d.z);
currentCell = navMesh.findClosestCell(newPos2d);
Vector3f newPos3d = new Vector3f(currentPos3d.x, currentPos3d.y, currentPos3d.z);
currentCell = navMesh.findClosestCell(newPos3d);
if (currentCell == null) {
return false;
}

goalPos3d = goal;
goalPos = new Vector2f(goalPos3d.getX(), goalPos3d.getZ());
Vector3f goalPos2d = new Vector3f(goalPos.getX(), 0, goalPos.getY());
goalCell = navMesh.findClosestCell(goalPos2d);
Vector3f goalPos3d = new Vector3f(goal.x,goal.y,goal.z);
goalCell = navMesh.findClosestCell(goalPos3d);
boolean result = buildNavigationPath(path, currentCell, currentPos3d, goalCell, goalPos3d, entityRadius, debugInfo);
if (!result) {
goalPos = null;
Expand Down

0 comments on commit e510a6f

Please sign in to comment.