No video

3D Pathfinding in Godot using Navigation Mesh

  Рет қаралды 12,080

Code with Tom

Code with Tom

Күн бұрын

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/cod...

Пікірлер: 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!
@__Rizzler__
@__Rizzler__ 2 жыл бұрын
Broo thank you. 🙏🙏🌹❤
@CodeWithTom
@CodeWithTom 2 жыл бұрын
You're very welcome :)
@tjspeirs75
@tjspeirs75 6 ай бұрын
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!
@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?
@IMidgetManI
@IMidgetManI 2 жыл бұрын
He's back
@CodeWithTom
@CodeWithTom 2 жыл бұрын
Glad to be back :)
@malcolminthemetal4992
@malcolminthemetal4992 Жыл бұрын
This is great. Thank you very much.
@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 6 ай бұрын
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 )
@mounaimchakroun6923
@mounaimchakroun6923 2 жыл бұрын
Thank you so much
@Alternalo
@Alternalo 2 жыл бұрын
What happens when you click on the top of the smaller cubes?
@al-oh8fq
@al-oh8fq 2 жыл бұрын
would it work with non static obstacles (like moving walls for example)?
@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.
@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)
@chrisspamtest
@chrisspamtest Жыл бұрын
Anyone got this to work? Nothing happens when I mouse click.
@ericomfg
@ericomfg Жыл бұрын
Where does global_transform come from?
@thimkthimk
@thimkthimk 11 ай бұрын
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.
@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 М.
Godot 4 3D - AI Pathfinding/Navigation
10:15
DevLogLogan
Рет қаралды 67 М.
Мы сделали гигантские сухарики!  #большаяеда
00:44
Prank vs Prank #shorts
00:28
Mr DegrEE
Рет қаралды 13 МЛН
I Took a LUNCHBAR OFF A Poster 🤯 #shorts
00:17
Wian
Рет қаралды 14 МЛН
How to Code Melee Attacks in Godot: Hitboxes and Hurtboxes
15:11
INVENTORY & ITEM SYSTEM in Godot
50:30
Code with Tom
Рет қаралды 56 М.
Enemy AI Series 1: The State Machine
12:10
Garbaj
Рет қаралды 51 М.
Simple Interactive Grass in Godot
13:17
Kasper Frandsen
Рет қаралды 35 М.
How To Make a 3D Line of Sight System in Godot in 9 Minutes
8:51
Phantasy Dev
Рет қаралды 10 М.
NEW Procedural Animation In Godot 4.0
9:26
Crigz Vs Game Dev
Рет қаралды 149 М.
How You Can Easily Make Your Code Simpler in Godot 4
6:59
Bitlytic
Рет қаралды 417 М.
Behavior tree AI in under 10 minutes! Godot 3.5 Tutorial
10:00
Import 3D Models From Blender into Godot - Godot Quick Tips
7:55
Code with Tom
Рет қаралды 77 М.
Мы сделали гигантские сухарики!  #большаяеда
00:44