MilosLukic / Godot-Navigation-Lite

Godot plug&play implementation of detour. It allows user to have multiple navigation meshes, fast cached obstacles, and realtime navmesh changes.
Other
132 stars 12 forks source link

find_path returns wrong path #11

Open Favkis opened 3 years ago

Favkis commented 3 years ago

https://user-images.githubusercontent.com/46406204/104125542-7a63d800-5368-11eb-85b2-c828c1ceefca.mp4

I use this to generate path: path=nav.find_path(self.global_transform.origin,pos)["points"]

This code draws yellow lines:

    for i in range(0,path.size()-1):
        DrawLine3D.DrawLine(path[i]+Vector3(0,1,0),path[i+1]+Vector3(0,1,0),Color(1,1,0),5)

I clicked somewhere right and it returns not straight line to there, but lines somewhere far left top (I used default navigation and it worked just fine. Raycast is fine cause I click on character first to select it and it selects correctly)

MilosLukic commented 3 years ago

I think there may be some offset issues, check this issue:

https://github.com/MilosLukic/Godot-Navigation-Lite/issues/4

I think that the (temporary) solution is to have the navmesh e.g. your terrain placed so that the 0.0 is at the center of the map.

Favkis commented 3 years ago

@MilosLukic I have everything in 0 cause I read that default godot navigation has issues if something is not at 0, so I always keep everything map related at 0.

Favkis commented 3 years ago

I also tried getting offset from point that had to be returned and what I've got, I tried offesetting both/either position that is returned,position on entrance and stuff, but no luck. Also weird thing is that it doesn't seem to be XZ offset, it ALWAYS makes point on the mountain, so maybe it thinks closest path is to go as high as possible, because weirdly enough when changing Y to input/output coords, it's either always on mountain or nowhere at all (probably same pos as where it's at already)

Favkis commented 3 years ago

I deleted generated collision covex and made simple box colision, and it fixed navigation image

However it means for this addon to work, collision has to be single box. I added second collisionshape to staticbody's map, second large box and it breaks path_find again image

Ok the problem is if any CollisionShape doesn't have translation 0 0 0, then all navigation breaks.

Now I tried to create multiple convex shapes, baked navigation and it's still broken.

Tried single convex shape, and when baking godot crashes.

Also weird thing is that when it breaks (if I use ANYTHING but box static body collision in 0 0 0, when it breaks, find_path only returns points at the points between navigation grid)

Favkis commented 3 years ago

testnavmeshproject.zip

MRP if anyone needs it