-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Add RVO collision avoidance #32557
Add RVO collision avoidance #32557
Conversation
PLEASE DO NOT MERGE YET. I'm confident there are memory leaks and a gazillion things wrong with this. |
Nice, I was considering doing this exact thing! |
This sounds really cool but what does it do exactly (I did see any additions to the docs in the commits). |
@asheraryam |
That looks great, there's even a 3d version that seems useful as well. |
Fixes #1887 |
@asheraryam the 3D version is much less useful than the 2D version for two reasons:
|
@nathanmerrill Sure I wasn't actually suggesting the 3D version be added to the engine, it's not useful for most people. (It's just useful for me personally since I'm currently working on a project with 3D navigation for dozen agents concurrently, but I use a custom 3d boids flocking code with the extra behaviours I want and that does good enough.) |
I'm looking at the docs, is it possible to use this as-is with the current Navigation node to adjust an agent's path? For example pass the resulting path array from Navigation to the RVO module and have it return an adjusted path that avoids the other actors? Almost no navigation happens on straight ground with no walls or gaps, so RVO on its own wouldn't help in any real scenario unless it can interface with Navigation. Edit2: From what I see the "navigate()" method in this PR directly changes the object's velocity, so it would not immediately work with common cases of how Navigation is usually used where the path array is used to iterate every frame and move() to the next point in the list. However, since RVO has an But I guess that could be out of the scope of this PR so it can wait :D Also great work looking forward to trying it out! |
Potentially, yes. I like the idea of having this as a separate module, but a tighter integration can definitely work.
The library I'm using doesn't handle multi-step path adjustments. The input to the algorithm is (1) All actor's current positions and velocity, and (2) the current actor's preferred velocity. It will then return an adjusted preferred velocity. If you are able to predict all of the actors' future position and velocity, then you could do this, but such an algorithm sounds difficult and makes a lot of assumptions. I have gotten this to work with Navigation2D. The key is that you using Navigation to generate the overall path, and then use collision avoidance to navigate actors each tick. A small issue with this is that actors likely won't hit each point of the path exactly, but the fix is to check if the actor is within a certain radius of their destination. |
That's not a bad way to go about it, it should work for Navigation in 3D as well 😄
Not sure if measuring distance from destination is a good fix, it could be a better idea to just demand a new The idea is that we usually navigate the simple_path by iterating over each point, if the agents go off the path then it's basically void and needs to be recalculated again. |
ec2dac6
to
1e88985
Compare
@nathanmerrill Can this be used to build custom behaviours? And change between then? E.g. is it handled in physics? Trying to understand how to use it properly for npcs in (wander / seek)... Are there any dependencies for compiling it on current stable version 3.1.1? |
@vini-guerrero there aren't any external dependencies. This is not handled by the physics engine at all. The core of the entire behavior lies in the |
Awesome work on that @nathanmerrill! I'm working on a project that depends on this but it's currently on 3.1.1, since this adds a new lib shouldn't break compatibility with older versions right? Right now, I'm handling everything inside physics and Area2D, could achieve a better performance specially for mobile... |
@vini-guerrero As far as Godot-dependencies, I depend on these types: Rect2, PoolVector2Array, Vector2, Vector, Node2D, and the parts that help expose my module. I don't know when those were added, but if they are missing/different in 3.1.1, then this won't work. |
@nathanmerrill These are all available in Godot 3.0 and later, it should be fine. |
Is this related to the module itself or my something wrong with my compile process?
|
@vini-guerrero I'm suspecting the warning at the start is the real problem:
I'm not sure why you are getting that warning, as it appears in the commit. |
Hey can we merge this into 3.2 I know we are in feature freeze but this is a mission critical feature for 3D Godot games. Collision avoidance is non existent because detour is not integrated into Godot. Here is some videos and a Issue to prove my point. |
I agree with @HeadClot - even with 4.0 "reworking everything", that's still quite a long ways away. This could serve as a holdover until then. |
What @Duroxxigar said. If that is not possible put it into a patch version like Godot 3.2.1 or whatever. |
Thank you @Calinou :) |
@@ -344,6 +344,11 @@ Comment: Recast | |||
Copyright: 2009, Mikko Mononen | |||
License: Zlib | |||
|
|||
Files: ./thirdparty/rvo2/ | |||
Comment: RVO2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What version of RVO is this? Is there a git hash or a version number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version 2.0.2. This is listed in thirdparty/README.md
Hey @nathanmerrill I'm working on top of this PR in order to use it for 3D objects too. I'm implementing it in a different way in order to "automatically" add the physics object in the RVO engine, and use the server code for both 2D and 3D. I would like to push my changes directly on this PR, so we can both contribute on this feature. Would you like that? |
@AndreaCatania I'm not sure what you mean. Are you talking about reusing CollisionObject as obstacles, and some other node as the actors? I don't think that is a good idea, as users may want to separate collision logic from collision avoidance. Regardless, I'm totally fine with you contributing a 3D version of this code. |
@nathanmerrill I've created a new PR, since in this way I'm faster: #34485 Thanks. |
@nathanmerrill By the way, we're discussing the upcoming navigation system in Godot 4.0 on IRC ( |
What's the status on this now that #34776 was merged? |
No description provided.