0 votes

I already created a scene with a camera,a player(physics body with mesh instance as child) and some other object(physics body with mesh instance as child)...
Now,how do I create pathfinding for the player,so that it goes where the user clicks?
I know navigation node and navigation mesh instance node need to be used,but I have no idea about anything else...

I've tried creating a navigation node..
Then in the script attached to the navigation node, I created some navigation mesh using the mesh of the mesh instance that is already in my scene and add it into navigation using navmesh_add()...
After that,I loop through the result of the get_simple_path() to draw the path using sphere,but the path is going through solid object,going into the ground,sometimes it would also return an empty array(no path)...

in Engine by (45 points)

This could be of interest for you: https://godotengine.org/asset-library/asset/124

I downloaded it,but I still don't understand...
I was hoping there's an online tutorial that have detailed explanation of how everything works and how it is implemented for games generated using procedural generation..

Actually what is navmesh for??
Is it for setting the area where the player can move or is it to set the area where the player can't move??

NavigationMeshInstance creates/'bakes' a walkable mesh. This mesh is created for the MeshInstance's that are children of the NavigationMeshInstance node. This NavigationMeshInstance node uses NavigationMesh data to bake to (the names are confusing but it's basically settings in the inspector). After this select the NavigationMeshInstance node and click bake at the top of the scene view.

Ok,thanks...I'll try that..
But I heard we can't bake navmesh in code...
So since I'm procedurally generating my world,how do I bake my navmesh?

I've tried that,see my main question for details...
And also they speak something about offset,what does it mean??

I'm not too sure, there's no description for create_from_mesh(Mesh mesh) but I would imagine it uses the mesh given rather than using the algorithm in the baking process so the offset would be for the NavigationMesh's cell height.

Ok,I've just done some research on pathfinding in Godot and I found out that there's a Astar class in Godot.
So since navigation is giving me problems,do u think Astar would be a good idea??

A* is nice for tile-based navigation, but it won't provide you with dynamic obstacle avoidance if you need it.

Please log in or register to answer this question.

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.