3D Pathfinding in Godot using Navigation Mesh

  Рет қаралды 11,957

Code with Tom

Code with Tom

2 жыл бұрын

Learn how to add 3D Pathfinding in Godot using Navigation Mesh in your projects by following this simple Godot tutorial.
You'll learn how to move a KinematicBody using the Navigation and NavigationMesh nodes in Godot. You could use this technique in a number of different games, for example an RTS or MOBA in Godot where you click to move around the map, or for controlling enemy pathfinding AI in Godot.
---
Patreon: / codewithtom
Discord: / discord
Twitter: / codewithtom
Github: github.com/codewithtom

Пікірлер: 37
@greg7987
@greg7987 2 жыл бұрын
A clear, simple and amazing video for learning 3D pathfinding in Godot it is.
@CodeWithTom
@CodeWithTom 2 жыл бұрын
Thank you Greg I appreciate that.
@Crisisdarkness
@Crisisdarkness 2 жыл бұрын
Wow, you came back with a great tutorial, thanks Tom
@CodeWithTom
@CodeWithTom 2 жыл бұрын
Thank you I really appreciate it!
@Gabirell
@Gabirell 2 жыл бұрын
Man… I was asking myself how this is implemented… (I’m a totally curious noob) and this seems so logic… saved for when I learn enough to understand it all. 🙏 thanks!!!
@zyxoto1264
@zyxoto1264 2 жыл бұрын
The legend is back
@CodeWithTom
@CodeWithTom 2 жыл бұрын
Haha thank you, good to be back!
@malcolminthemetal4992
@malcolminthemetal4992 Жыл бұрын
This is great. Thank you very much.
@__Rizzler__
@__Rizzler__ 2 жыл бұрын
Broo thank you. 🙏🙏🌹❤
@CodeWithTom
@CodeWithTom 2 жыл бұрын
You're very welcome :)
@p.w.5813
@p.w.5813 2 жыл бұрын
Thanks for that tutorial, but I still have a problem. My map is not flat like yours, it has hills and valleys. Is there a way to use path finding in such conditions?
@al-oh8fq
@al-oh8fq 2 жыл бұрын
would it work with non static obstacles (like moving walls for example)?
@mounaimchakroun6923
@mounaimchakroun6923 2 жыл бұрын
Thank you so much
@projectavalongame
@projectavalongame 2 жыл бұрын
Hey mate thanks for the tutorial. Could you do a tutorial on making the character face towards the direction they are moving? I use the look_at function but it will look directly at where I clicked, so they will do a crab walk around an obstacle (move sidways while looking directly at the mouse click rather than the direction they are moving.)
@Pirochiro
@Pirochiro Жыл бұрын
Not sure if you figured this out but you if you look at direction instead of the target, the player will always look in the direction they are moving.
@IMidgetManI
@IMidgetManI 2 жыл бұрын
He's back
@CodeWithTom
@CodeWithTom 2 жыл бұрын
Glad to be back :)
@tjspeirs75
@tjspeirs75 5 ай бұрын
Great video! Am I right in thinking that that navigation code could be sectioned off into it's own script and used as a component? And then that component could just be dropped onto anything that needs it? Seems like it'd work great!
@Alternalo
@Alternalo 2 жыл бұрын
What happens when you click on the top of the smaller cubes?
@PunyFlash
@PunyFlash 2 жыл бұрын
The ray is colliding with the collision shape of the kinematic body
@Ceisriel
@Ceisriel Жыл бұрын
is navmesh as useless as gmesh? in the sense it's only for demos or can you use that with actual 3d terrain sculpted in blender?
@wexordante
@wexordante 5 ай бұрын
I can't search tutorial about turn-based strategy movement in 3d. If you can, pleace, say me what I should or create a tutorial in your chanel. Thanks )
@chrisspamtest
@chrisspamtest Жыл бұрын
Anyone got this to work? Nothing happens when I mouse click.
@ericomfg
@ericomfg Жыл бұрын
Where does global_transform come from?
@thimkthimk
@thimkthimk 10 ай бұрын
It's the position of the node in world space. KinematicBody (now CharacterBody3D in Godot 4) inherits from Node3D and therefore can use it's properties, like global_transform.
@bronxzoo8344
@bronxzoo8344 Жыл бұрын
nobody has anything that will help with enemy facing the player with navigation, Cane you help. Thank you.
@zapman6528
@zapman6528 Жыл бұрын
Make the enemy model a child of the kinematic, then through code have the model face the player. I cant help with the code part but thats how you'd have to organize it.
@coder-serwin3545
@coder-serwin3545 2 жыл бұрын
Bro can you make this with enemy that wants to follow player please
@CodeWithTom
@CodeWithTom 2 жыл бұрын
Good suggestion :)
@coder-serwin3545
@coder-serwin3545 2 жыл бұрын
@@CodeWithTom :)
@Arun--AK
@Arun--AK 2 жыл бұрын
Start a new series to make TPS game bro
@CodeWithTom
@CodeWithTom 2 жыл бұрын
I'd love to make a series on making a TPS, it's definitely on my list of things to cover.
@zapman6528
@zapman6528 Жыл бұрын
The code: extends KinematicBody export var speed = 10 onready var camera = $"../Camera" onready var navigation = $"../Navigation" var space_state : PhysicsDirectSpaceState var path = [] var path_index = 0 func _ready(): space_state = get_world().direct_space_state func _input(event): var mouse_event = event as InputEventMouseButton if mouse_event == null: return if mouse_event.pressed and mouse_event.button_index == 1: var from = camera.project_ray_origin(mouse_event.position) var to = from + camera.project_ray_normal(mouse_event.position) * 1000 var result = space_state.intersect_ray(from, to) if result.collider: path = navigation.get_simple_path(global_transform.origin, result.position) path_index = 0 func _physics_process(delta): if path_index < path.size(): var direction = path[path_index] if direction.length() < 1: path_index += 1 else: move_and_slide(direction.normalized() * speed)
@p.w.5813
@p.w.5813 2 жыл бұрын
Thanks for that tutorial, but I still have a problem. My map is not flat like yours, it has hills and valleys. Is there a way to use path finding in such conditions?
@Ceisriel
@Ceisriel Жыл бұрын
did you figure it out I'm asking everywhere and no one can answer
@p.w.5813
@p.w.5813 Жыл бұрын
@@Ceisriel sorry mate, I didn't
@Ceisriel
@Ceisriel Жыл бұрын
@@p.w.5813 fortunately I did, you have to put your terrain mesh under the navmesh node, and if you can't do that, you right click on the main node of the terrain, and select "change type" you change it to navmesh and then click the bake mesh button , and then you need to re add all the collisions. It's very inefficient, slow and pretty much useless because if your terrain has more than 4k polygons the game engine starts to freeze or crash as it is baking
How to make a game when your art sucks!
3:41
Code with Tom
Рет қаралды 6 М.
Loops, Signals, get_node & call_deferred in GDScript
14:44
Code with Tom
Рет қаралды 18 М.
Русалка
01:00
История одного вокалиста
Рет қаралды 7 МЛН
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 57 МЛН
Double Stacked Pizza @Lionfield @ChefRush
00:33
albert_cancook
Рет қаралды 60 МЛН
INVENTORY & ITEM SYSTEM in Godot
50:30
Code with Tom
Рет қаралды 55 М.
Setting up 3d Pathfinding in Mins | Godot
16:01
rayuse rp
Рет қаралды 23 М.
Weapon Camera & Aim Down Sights - Make an FPS in Godot Part 5
23:49
Code with Tom
Рет қаралды 25 М.
Godot 4 3D - AI Pathfinding/Navigation
10:15
DevLogLogan
Рет қаралды 62 М.
[Tutorial] 3D Astar Pathfinding with Gridmaps in Godot 3
14:28
Third Person Character Controller in Godot 3.2
29:09
Code with Tom
Рет қаралды 45 М.
Creating a Diablo Like Click To Move System in Godot 4
29:55
FinePointCGI
Рет қаралды 21 М.
Foliage Painting in Godot 4 (Multimesh Addon)
29:23
Michael Jared
Рет қаралды 1,8 М.
Русалка
01:00
История одного вокалиста
Рет қаралды 7 МЛН