Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navmesh not optimal #17885

Closed
DevMagicLord opened this issue Mar 31, 2018 · 29 comments
Closed

Navmesh not optimal #17885

DevMagicLord opened this issue Mar 31, 2018 · 29 comments

Comments

@DevMagicLord
Copy link

DevMagicLord commented Mar 31, 2018

Godot 3.0.2 - Windows

Hi there,
I have issues with navmesh :

  • Navmesh pathfinding sometimes calculates a long path while a shortest is available.
    You can test an exemple moving a ball with keys "azqd" , navmesh characters will move and will not take the shortest path.
    https://github.com/DevMagicLord/Godot3/blob/master/projects/nav%20controllers/nav_controllers.zip

  • There is no option to tell navmesh a maximum of points we want when we request a path
    A path returns more than 30 points while sometimes 5 or 10 would be enough.
    Navmesh needs an option to specify if we want more or less segment paths.

  • There is no method to get a random point inside navmesh, or to tell if a point is inside or not navmesh.

  • Godot needs higher level of abstraction for navmesh, a new node NavAgent
    This node should be included in Godot as native C++.
    It would take care of acceleration, deceleration, stopping distance, turn speed, agent radius and avoidance. NavAgent will have methods like setDestination, stop, resume, cancel movement.

@DevMagicLord
Copy link
Author

Should we expect it for 3.1 or 3.2 release ?

@vnen
Copy link
Member

vnen commented Apr 24, 2018

Should we expect it for 3.1 or 3.2 release ?

Not unless someone steps up and decide to work on it.

@DevMagicLord
Copy link
Author

DevMagicLord commented Apr 24, 2018

It's on C++ engine side this must be included, GDscript is too slow to handle multiple Navmesh Agents or do the path calculation for each.

Multi threaded Navmesh calculation and Namesh Agent components or nodes are essential for most 3D games about characters and AI.

Why this is not a priority when this is engine 3D game fundation ?

@DevMagicLord
Copy link
Author

I would hope navmesh functions that are an important feature for 3D games
would get improvments for 3.1 ?
Or should we expect those on some 3.2 ?

@DevMagicLord
Copy link
Author

New features.

  1. Support for multiple navmesh per level
    A scene could have multiple sub levels each with their own navmesh.
    When an AI character queries a path, a scene global navmesh manager will find the closest navmesh and request a path on it.

  2. Tiled navmesh
    This could perhaps be more efficient to have navmesh tiled in squares grid with adjustable sizes.
    Query a paths could be faster on very large scenes.

@DevMagicLord
Copy link
Author

It is confirmed Navmesh will be worked on after 3.1 ?

Will it support DetourCrowd like Armory3D ?

@Anudin
Copy link

Anudin commented Sep 15, 2018

Just wanted to bump the issue of not optimal nav meshes. The resulting paths are often very obviously not the shortest ones which quickly kills immersion. @DevMagicLord wouldn't it be better to open seperate issues for your other suggestions though?

Edit: The paths are not the shortest ones.

@akien-mga akien-mga added this to the 3.2 milestone Sep 15, 2018
@akien-mga
Copy link
Member

Navigation issues are planned to be reviewed for Godot 3.2.

@Piet-G
Copy link
Contributor

Piet-G commented Sep 21, 2018

The Navagiation pathfinding not finding the shortest path should've been solved by #22047

@volzhs
Copy link
Contributor

volzhs commented Sep 21, 2018

I think @dualmatrix would say that it's solved. 😄
did I understand correctly?

@akien-mga
Copy link
Member

Great, closing as fixed by #22047.

@akien-mga
Copy link
Member

Ah well there are other issues in the OP, reopening...

@akien-mga akien-mga reopened this Sep 21, 2018
@Piet-G
Copy link
Contributor

Piet-G commented Sep 21, 2018

@volzhs Yeah I think it's solved, just havent tested.

@DevMagicLord
Copy link
Author

DevMagicLord commented Sep 22, 2018

Just wanted to bump the issue of not optimal nav meshes. The resulting paths are often very obviously not the shortest ones which quickly kills immersion. @DevMagicLord wouldn't it be better to open seperate issues for your other suggestions though?

Edit: The paths are not the shortest ones.

The other issue is path calculation must be native , not GDscript.
All navmesh must be native :

  • multi threaded navmesh process
  • agent nodes

Like Unity or UE4, you adjust your agent settings and call functions like MoveToDestination, Pause, Stop, Resume.
You should node have navmesh process code in GDscript, only calls to navmesh Api.

Native code for maximum performance.

@NewNodeGames
Copy link

Right, this is very important on actual games and It should be a priority. I tried to adapt to 3D some pathfinding projects like https://github.com/GDquest/Godot-engine-tutorial-demos/tree/master/2018/03-30-astar-pathfinding and https://github.com/FEDE0D/godot-pathfinding2d-demo with no luck. If someone knows something about this please answer.

@reduz
Copy link
Member

reduz commented Nov 30, 2018

Will hopefully be able to do optimize and add more pathfinding features after 3.1 is out

@DevMagicLord
Copy link
Author

DevMagicLord commented Jan 15, 2019

Will there be some NavAgent new node able to work with Kinematic or RigidBody physics ?

https://docs.unity3d.com/uploads/Main/NavMeshAgent.png

https://docs.unity3d.com/Manual/nav-MoveToDestination.html

What about some central multi threaded navmesh system dealing with each navAgent pathfinding requests ?
(So we don't need to deal with navmesh low level movement and pathfinding code)

I didn't seen any Navmesh features in Godot 4.0 roadmap.
It is really planned after 3.1 is released ?

@Toshiwoz
Copy link
Contributor

Toshiwoz commented May 2, 2019

This is a good moment to work on this, maybe? 3.1.1 is out.

Waiting for Godot 3.2

bojidar-bg added a commit to bojidar-bg/godot that referenced this issue May 3, 2019
@akien-mga
Copy link
Member

The first point is solved in #28640.

kiku-jw added a commit to kiku-jw/godot that referenced this issue May 16, 2019
* [TileMapEditor] Improve tool picking usability

When KEY_CONTROL is released, go back to the last tool.

Also add a tooltip for paint button with shortcuts for line draw and
rectangle paint.

* Make buttons that trigger popups have the same scale

* Make 'Line/TextEdit's context menus hide their editing options when in readonly mode

Fixes godotengine#28243.

* Renames captions of Scalar/VectorInterp in Visual Shaders

* Warn when opening imported anim in AnimationPlayer

* C#: Support resource type hint in exported arrays

- Elements of types like PackedScene will display with the special editor for such type.

* Fixed GLES2 transparency order

* Added an is_valid function to FuncRef so script can check if it is safe to call it.

* issue-28446 - disable higlighting all occurences of string in editor if only whitespaces are selected

* Set range for line spacing

* Fixed a few issues with the bezier animation track editor, fixed the Travis CI errors, added TTR to bezier value labels and rounded them to 3 decimal points

* Add and expose to Font a function to get the rect size needed to draw a word-wraped text

* Fix build error after godotengine#27294

* SCons: Always use env.Prepend for CPPPATH

Include paths are processed from left to right, so we use Prepend to
ensure that paths to bundled thirdparty files will have precedence over
system paths (e.g. `/usr/include` should have lowest priority).

* Properly expose PhysicsServer methods

* Forgot a parameter in the ARVR gdnative bindings for notifications

* Fix sign-compare error from godotengine#26051

* doc: Sync classref with current source

* GridMap editor fixes and improvements

This change fixes a few outstanding issues and greatly improves the usability
of the GridMap editor through the following changes:

- Copied mesh now gets displayed during pasting (also renamed the related
  identifiers accordingly)
- Duplication/paste indicator now gets rotated around the correct pivot point
  (duplication worked properly before, but the indicator was shown misplaced
  when rotated)
- Selected mesh library item cursor is no longer shown during selection and
  duplication/pasting
- Back rotate X/Y/Z is now working during duplication/pasting
- Added true cut operation thanks to now having a proper clipboard (clear
  operation got remapped to the DEL key)
- Got rid of some weird workarounds in the duplication code
- Fill and clear operations now correctly make the selection marker inactive
  as this was broken partly due to the workarounds mentioned above
  (duplication continues to keep the selection marker active to allow
  subsequent duplications)
- Clear current selection on RMB, but treat selection as an action so previous
  selection can be restored on undo
- Separated selection and paste indicator data as it's prone to error and
  confusion and it's anyway needed now that selection is treated as an action
- Added support for cancelling paste, selection, and even unselect the
  currently selected mesh library item with the ESC key (previously there
  wasn't a way to unselect)
- Changed the key binding of fill/clear/duplicate operations to use Ctrl as a
  modifier
- Changed erase to use RMB instead of Shift+RMB (free look is available
  through Shift+F anyway, so no need to occupy RMB for it during gridmap
  editing)
- Removed unused area, external connector, and configure menu items (there's
  also the non-functional clip mode menu items, but I'm not sure whether there
  are any plans with that, I suppose it's meant to be an editor aid)
- Renamed INPUT_COPY to INPUT_PICK to better reflect its purpose
- Added support for using Shift+Q and Shift+E to select multiple floors/planes
  without actually changing the current floor/plane as it happens when using
  e.g. the mouse wheel

Fixes godotengine#25373 and godotengine#15883

* Fix script dialog path validation to handle spaces correctly

* fixes bug when setting projection matrix

* Make "decimal" functions more consistent

In GDScript, rename "decimals" to "step_decimals". In C#, add "StepDecimals", but keep the old functionality in a method called "DecimalCount".

* Fix missing argument for vsnprintf_s

* fixes 27543, adds a copy button for the editor log

* Fix regression on 'PopupMenu's minimal size

* Fixed game crash, regression of godotengine#26977

Co-authored-by: bruvzg <7645683+bruvzg@users.noreply.github.com>

* Small documentation improvements

* Fix pvrtc encoder
Always resize image to square of power2
Enable mipmaps only if original texture has it enabled
Fix godotengine#28534, godotengine#28541

* Support Mac OS default move cursor hotkeys

Add missing FALLTHROUGH define

* Fix Remove Missing Project projects on Windows

* Revert "Update libwebsockets to 3.1 (plus UWP patch)"

This reverts commit 90210c4.

* Added missed inputs for other modes in visual shaders

* Change order of Visual Script Search.

Previously:

* vs nodes
* properties
* methods

Now:

* properties
* methods
* vs nodes

* VS: Better ux

* In VS functions' put the current node type first.
* Cleanup and merge property and method sections.

* VS: Give the generic search the current base type.

* Freetype clone env for no-SMID single file

Fix freetype build issue for javascript platform.
When disabling optimizations (SMID) in specific freetype, source files,
we need to make sure to copy all other CPPFLAGS, not just override them.

* Fix First Ctrl+R and Ctrl+F not showing long name variables correctly

* Add a property hint for DynamicFont size

This caps its size to reasonable values in the Inspector.

This closes godotengine#22581.

* Fix input entries when switching to new visual shader

* Locales: Add some missing locale names

* Ignore a warning in _get_socket_error (-Wlogical-op).

drivers/unix/net_socket_posix.cpp: In member function 'NetSocketPosix::NetError NetSocketPosix::_get_socket_error()':
drivers/unix/net_socket_posix.cpp:197:22: warning: logical 'or' of equal expressions [-Wlogical-op]
  197 |  if (errno == EAGAIN || errno == EWOULDBLOCK)
      |                      ^

and:

modules/mono/utils/string_utils.cpp: In function 'int {anonymous}::sfind(const String&, int)':
modules/mono/utils/string_utils.cpp:68:48: error: logical 'or' of collectively exhaustive tests is always true [-Werror=logical-op]
      found = src[read_pos] == 's' || (c >= '0' || c <= '4');
                                       ~~~~~~~~~^~~~~~~~~~~

* Fix typed arrays and dictionaries getting their values shared

* Document CollisionObject2D pickable requires collision_layer

Documents CollisionObject2D mouse_entered, mouse_exited and input_event requiring at least one collision_layer to be set.

* Fix slight issues with autocompletion and member lists in GDScript

Fixes godotengine#27152
Fixes godotengine#28591

* Fix regression in 'PopupMenu' when icons have different values for width and height

* Fix script dialog asking for correct inheritance when not needed

* Make small changes to the script dialog

* Add "disabled" icon for 'CheckButton'

* Hide "Built-in Script" option in the script creation dialog when not possible

* Fix Mac OS move cursor behaviour

* added MSAA to GLES backend

* Make "Find in Files" always available in the script editor

* Fix build visual_shader_editor_plugin

* Remove unused `panelf` and `panelnc` styles

Fixes godotengine/godot-docs#2426

* Fix collapse visual shader tree

* Fix navmesh not finding optimal paths

Addresses part of godotengine#17885

* Update of RigidBody2D class description

Added a hint in the RigidBody2D class description regarding the transformation issue mentioned in godotengine#5734

* Make 'TabContainer' update when icon/title is changed

Fixes godotengine#28655.

* Fixes VideostreamGDNative crash on audio_channel=0.

Added an if case to check if the mix_callback exists before running any
of the audio code.

Fixes: godotengine#28644

* Support Mac OS default delete char hotkeys

* Document dictionary erase return value

* Fix ParallaxBackground breaking when moving it out the scene tree

* fix CollisonShape changing shape cause crash when not in a tree

* Fix generation of Mono Glue for Visual Studio 2017+

vsnprintf definition should only be changed when MSC version is older than 2013. The version check and fix is taken from StringUtils.h of assimp.

* Fix 'TabContainer' not updating its tab titles when locale is changed

* Make editor close empty scene when creating an inherited one

Fixes godotengine#28654.

* Update AUTHORS and DONORS list

New contributors added to AUTHORS:
@Kanabenki, @KoBeWi

Thanks to all contributors and donors for making Godot possible!

* Remove reduz from some autorequested code reviews

He's still one of the main architects of some of these code branches,
but quite often PRs that modify one or two files in such folders don't
necessarily need his input, and he has enough backlog to handle.

PR triagers will ask for his review manually whenever relevant. He's
left as code owner for physics/visual servers and rendering backends.

* Center shape according to logic Bullet applies

* Add transform support to deal with Bullets centering of shapes

* Fix SHADOWS_DISABLED flag in GLES2

Signed-off-by: Guilherme Souza <gdsdsilva@inf.ufpel.edu.br>

* Improved the AnimatedSprite docs; added description to speed_scale.

* Revert "Merge pull request godotengine#28715 from YeldhamDev/inherent_scene_close_empty"

This reverts commit 0f8356d, reversing
changes made to 7b7a664.

* Change empty scene closing on new inherented scene to a better approach

* Fix texture resource reload bug

If a non-imported texture resource file (e.g. DDS) gets updated the editor
doesn't reload it. The cause of the problem is two-fold:

First, the code of ImageTexture assumes that textures are always imported
from an image, but that's not the case for e.g. DDS. This change thus adds
code to issue a resource reload in case an image reload is not possible
(which is the case for non-imported texture resources).

Second, the code is filled with bogus calls to Image::get_image_data_size()
to determine the mipmap offset when that should be done using
Image::get_image_mipmap_offset(). Previous code literally passed the integer
mip level value to Image::get_image_data_size() where that actually expects
a boolean. Thus this part of the change might actually solve some other
issues as well.

To be pedantic, the texture_get_data() funciton of the rasterizer drivers is
still quite a mess, as it only ever returns the whole mipchain when
GLES_OVER_GL is set (practically only on desktop builds) but this change does
not attempt to resolve that.

* Docs: Add tutorials for KinematicBody2D

* Revert "Merge pull request godotengine#26053 from qarmin/back_scroll_to_start"

This reverts commit b5deb1d, reversing
changes made to 2cc8848.

This change causes unwanted regression.
It's too risky to have scroll back to top in ItemList.clear()

* Scroll back to top when changing directory in FileSystem dock

Fix godotengine#26041

* [EditorSpatialGizmo] Fix error in intersect_ray

* Avoid _can_call_mode resetting error message in MultiplayerAPI

* Change "ID" to lowercase "id"

Reasoning: ID is not an acronym, it is simply short for identification, so it logically should not be capitalized. But even if it was an acronym, other acronyms in Godot are not capitalized, like p_rid, p_ip, and p_json.

* Fix AudioEffectRecord messing up the effect stack by not writing to dst_frames

* X11: Check if "_NET_FRAME_EXTENTS" atom is supported.

* Fixes to ClippedCamera

This work has been kindly sponsored by IMVU.

* Allow or_greater for most properties of NavMesh

Closes godotengine#28624

* Open selected folder when pressing the "Open" option in the menu

An attempt to fix godotengine#28798

* Add RegEx substitution testcase and fix relevant docs

(cherry picked from commit a31bbb4)

* Make possible to create inherited scenes via the RMB menu in the FileSystem dock

* Fix orientation of generated navmeshes

Fixes godotengine#23817

* Apply sprite frames editor FPS value correctly upon _animation_select

* updated description of Array.shuffle to properly describe that it uses the same common seed at every runtime, thus being reproducible in general

* AnimatedSprite: Add from spritesheets now work as expected. Fix godotengine#28030

* Better handle some self-RSET/RPC in MultiplayerAPI

Allow calling yourself via RPC/RSET if the mode allows it.
Better error messages when you are not allowed to call yourself.

* Fix GDNative library resource loading.

Store general properties in ConfigFile too when modifying them.
Additionally set config_file property as internal as it's not editable
from inspector. It also does not appear to get saved in a meaningful way
(saved as Object(ConfigFile, ...))

* added radiance when using clear color and fixed brdf

* Properly update script button when undoing a script addition

Fixes godotengine#28870.

* Improve the CanvasItem documentation

This makes it clear that line width and antialiasing in
`draw_multiline()` aren't implemented yet (see godotengine#16448).

* Make Xcode recursive search frameworks in project dir

* fix lighting bug introduced in clear color changes

* Fix NaN with get_action_strength

* doc: Sync classref with current source

* doc: Fix issues found by the parser

* Update GDNativeLibrarySingletonEditor.

Moved GDNative singletons discoverer from register_types to
GDNativeSingletonEditor.
Fix enable/disable switch in GDNativeLibrarySingletonEditor.
Separate `gdnative/singletons` and `gdnative/singletons_disabled`
project settings, keeping "on by default" behavior.

* Fix OS_Javascript execute method

Signature was changed in OS via:

cd4449e

* Fix indexing failure in NativeScriptLanguage::unregister_binding_functions.

binding_functions.size() and an instance's binding_data.size() can get out of sync. They sync up when an instance's bindings are requested. When binding functions are registered after creating an instance's bindings, the instance's bindings are out of sync until requested again. If they're never requested, they're never synced.

unregister_binding_functions indexes into binding_data, but only checks that its safe to index into binding_functions. When they're out of sync, indexing fails.

This revision checks that it's safe to index into binding_data.

* Fix OS_UWP::execute's signature after cd4449e

Same as godotengine#28919.

* Revert "Revert "Implemented terrain raycast acceleration""
@TheSHEEEP
Copy link

TheSHEEEP commented Jun 5, 2019

Will the inclusion of navigation agents be part of the 3.2 rework of the Navigation? I mean, beyond the bugfixing and allowing to create navmeshes from meshes at runtime.

Frankly speaking, without proper agent navigation, Godot is dead in the water for any project that has multiple entities requiring navigation in 3D at realtime while also requiring those to avoid each other. I consider this the primary feature missing in Godot to be usable for most larger-scale 3D projects.

And that's a damn shame, because this is really the only "blocking" feature I see. Graphics? Yup. Audio? Yup. Physics? Yup. Input? Yup. Networking? Yup. Awesome editor? Yup. Scripting/modding? Yup. All improvable, I'm sure, but very much usable and present. Pathfinding? Errhh... not really.
Sure, you can get a path from A to B, but that isn't the hardest part about pathfinding in realtime games, dynamic obstacle and other agent avoidance is.

At the moment, I really wouldn't see a way to create an RTS-style game in 3D or any 3D game with multiple NPCs seeking cover, using the environment etc. without extreme workarounds like rolling your own agent avoidance, custom navigation AI, making navigation grid-based to use Astar (which will look clunky if your world isn't grid-based) or "just" implementing Detour/DetourCrowd yourself.

I ask because I wonder what priority this is given internally and if I should consider to use 3.2 for a project or not.

@MilosLukic
Copy link

MilosLukic commented Jul 28, 2019

I didn't know where alse to turn to, so I am writing here, I use the 3.2 dev build, and the navigation system works perfectly if you use a plane and nothing else. As soon as I add a few objects, it fails miserably, I created a simple use case - two units, which I want to move to a new location, which is reachable by pretty straightforward line, yet the get_simple_path returns a path that goes around the objects (picture available here. I also tried changing the parameters a bit, but with no luck. I see that there were some commits that claim to fix the non optimal path issue, so I wonder, am I missing something (parameters, navmesh type?) or is it still a bug that is being worked on.

@DevMagicLord
Copy link
Author

The request was to get something more optimized and as intuitive and easy to use as the other popular 3D engines ( easy baking with options, easy nav agents setup also able to work with characters physics , performance multithreading with calculation routines all written in C++ ).

Since Mars 2018, it is not more people using Godot for 3D, and needing AI to be able to navigate anywhere on a level ?

Can we expect something lot more later after Vulkan and other things are ready ?

@TristanAppDev

This comment has been minimized.

@Calinou
Copy link
Member

Calinou commented Aug 20, 2019

@TristanAppDev Please don't bump issues without contributing significant new information; use the 👍 reaction button on the first post instead.

@mitchcurtis
Copy link
Contributor

Avoidance is also covered by #1887.

@Chaosus Chaosus modified the milestones: 3.2, 4.0 Sep 12, 2019
@MilosLukic
Copy link

MilosLukic commented Oct 13, 2019

Since the project from the first post is for 3.0 and there is some "space" deleting to be done for 3.2, I created another test project (in 3.2), which includes two scenes. One with flat terrain and another with "pretty" flat terrain, but with small "hills" with few degree slopes.

Here is a picture of two paths for almost the same start and destination for the first scene:
3d_terrain_flat
The purple line is right, but the orange goes a long way around objects. It's not the shortest path.

Even worse situation is with the second scene. In that case, even the first path is not the shortest.
3d_terrain

Here is the test project
nav_test.zip

I'm no expert here, but it seems to me that there could be a problem either with the A* get_simple_path (though it's true that id doesn't say get_shortest_path), or with a Navmesh, in which case the problem could be either in parameters I used for generation (I used the default, maybe default should be different?) or generation itself.

@Duroxxigar
Copy link
Contributor

I believe the crux of this has been solved by #34776.

@TheSHEEEP
Copy link

Since the new Navigation won't be in 3.2, I bit the bullet and created my own 3D navigation for Godot 3.2:
https://github.com/TheSHEEEP/godotdetour

(not sure if this should be here, but I felt that many people found this issue looking for a 3.X solution, so...)

@Calinou
Copy link
Member

Calinou commented Jun 5, 2020

This was most likely resolved by #34776, closing. See #17885 (comment) if you need a solution in Godot 3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests