Closed orion3dgames closed 1 year ago
Ok, after digging into yuka internal working, if I do the following change to yuka.js, everything works as I want....
I was assuming yuka returned an empty array if no valid path was found.... Does this mean, I'm not using using Yuka the way it was intended? Any suggestions?
I was assuming yuka returned an empty array if no valid path was found
That is unfortunately not correct. NavMesh.findPath()
always returns a path. If the start and end points lie outside of the nav mesh, the implementation tries to find the closest region so a path can be returned.
Navigation is a complex topic in games. And doing it automatically right for all use cases is tricky for an AI engine. Depending on your application logic, you often know that the start and end position of a game entity lie on your nav mesh. Sometimes you don't and automatic region assignment is unwanted since you don't want the AI to move. In this case, use NavMesh.getRegionForPoint()
to find out whether a point (e.g. the game entities destination point) lies insides the level/navmesh. If not, don't trigger a path search via NavMesh.findPath()
.
@Mugen87 Yes, I realize that now and it make sense 100%.
I cannot wait to dig in and see what I can manage to do. I think we can close this now.
Many thanks for taking the time to explain.
ps: i feel a little silly now spending over a month trying to figure it out, looking in the wrong area, and making assumptions.
EDIT : I"VE RESTARTED THE DEMO SERVER AS IT WAS VERY LAGGY.
Hi there,
I've been trying for over a month to get YUKA integrated into my game with no success, but I refused to give up because it is exactly what I need and would be a tremendous amount of work to do myself.
PUBLIC REPO HERE: GITHUB REPO
DEMO HERE SHOWING ISSUE
CLICK FOR DEMO LINK HERE : As you can see, it looks like the navmesh & graph is loaded correctly but findPath is never false so I cannot detect any collisions.
WHAT IS WRONG AND WHAT AM I EXPECTING
I'm expecting foundPath constant below to be false when I move off the navmesh
SNAPSHOT OF MAIN CODE
NAVMESH CAN BE FOUND HERE:
all navemesh can be found here: https://github.com/oriongunning/t5c/tree/main/public/models/navmesh
Many thanks, Orion