+1 vote

How does we implement obstacle avoidance dynamically in Godot 3D? From what I have searched so far it seems like it is not possible to do so till Godot 4.0 is released.

But even then, I want to learn about pathfinding, as I want to implement some of the path movements like in games such as Age of Empires and Total War, where there are these cool formations and a lot of other things.

But I am kind of confused about terminologies related to pathfinding. As most of the tutorial I see online are related to A* algorithm which I believe is a path finding algorithm, but it turns out that there is some other technique used for avoiding collision among moving enemies. I guess we call it obstacle avoidance?

Either way, from where can I learn about these things. Are there any good free resources out there on internet. Or is there any good books or something. I really don't know where to start. Any advice is greatly appreciated. Thank You! :)

in Engine by (13 points)

1 Answer

+1 vote

I tried making obstacle avoidance by altering the get_simple_path points directly. Here's a GitHub link to it. I also posted a small demo on Reddit but the video only plays on desktop.

by (3,223 points)

I saw your demo video and it is working really good. Though it looks like it will take me some time to understand the code properly. As of writing I haven't read it thoroughly though. But at the same time, how are you implementing obstacle avoidance. And what resources would you recommend me to understand more about how to implement obstacle avoidance. Because on internet I don't see enough results, except for many many research papers ( which looks really intimidating to me lol ). Or it could be also that I am putting the wrong keywords in search.

Right now though, I am fine tuning my knowledge of pathfinding algorithms like A* and some other. And my end goal is to be able to have a system like in Age of Empires/Total War games, where units move in a specific formation and also avoid obstacles along the way (static and dynamic both).

My approach to it was like I mentioned above 'by altering the get_simple_path points directly'. It iterates through each agent's path points and finds the points within its radius. For each of those points it calculates where that point would go and uses intersect_ray to check if there's anything in the way, if so it checks the other side and moves the point accordingly.

I didn't study any kind of pathfinding or obstacle avoidance to make it, I just had an idea of how to go about making it in gdscript. However because obstacle avoidance isn't eccentric to any particular engine I'd recommend looking through sites like Stack Overflow because that won't be as intimidating as a research paper or manual.

Thanks for the information. That helps a lot :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.