Skip to content

Commit e510a6f

Browse files
authored
Merge pull request #1 from Ali-RS/Fix3DPathfind
Consider cell heights when finding path
2 parents 80e04ca + c81e15a commit e510a6f

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

AI/src/com/jme3/ai/navmesh/NavMeshPathfinder.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,14 @@ public boolean computePath(Vector3f goal) {
113113
*/
114114
public boolean computePath(Vector3f goal, DebugInfo debugInfo) {
115115
// get the cell that this point is in
116-
Vector3f newPos2d = new Vector3f(currentPos3d.x, 0, currentPos3d.z);
117-
currentCell = navMesh.findClosestCell(newPos2d);
116+
Vector3f newPos3d = new Vector3f(currentPos3d.x, currentPos3d.y, currentPos3d.z);
117+
currentCell = navMesh.findClosestCell(newPos3d);
118118
if (currentCell == null) {
119119
return false;
120120
}
121121

122-
goalPos3d = goal;
123-
goalPos = new Vector2f(goalPos3d.getX(), goalPos3d.getZ());
124-
Vector3f goalPos2d = new Vector3f(goalPos.getX(), 0, goalPos.getY());
125-
goalCell = navMesh.findClosestCell(goalPos2d);
122+
Vector3f goalPos3d = new Vector3f(goal.x,goal.y,goal.z);
123+
goalCell = navMesh.findClosestCell(goalPos3d);
126124
boolean result = buildNavigationPath(path, currentCell, currentPos3d, goalCell, goalPos3d, entityRadius, debugInfo);
127125
if (!result) {
128126
goalPos = null;

0 commit comments

Comments
 (0)