I was just about to comment that for some reason it isn't working now. I looked through to documentation but can't seem to see what is different. I literally chose the wrong time to finally do this tutorial lol.
reading that documentation causes me physical pain, it has to be the least useful documentation I have read for a programming language and my code no work
TH-cam search feature is so bad that even though i am subscribed to your channel and searching with exact words pathfinding enemy etc it did not show me that you have already made a video on this topic and such an advance toturial as well exactly what i was looking for TH-cam algorithm is so bad you deserve more subscriber thank god i was looking at your channel today for relevent or similar video otherwise i would have wasted another day . Your channel cover so many advance topics that no one else in the community does thank you so much
I have a similar system for the nav, but am struggling with avoidance, I basically want the enemies to stay off the walls and not slide along them so much. It is a TD hobby project, and I have enemies just lining up whenever there is a corner. Is there a way to "spread them out" when you are letting them navigate?
line 19 and 22 complains about not beeing able to call non static functions on the class navigationagent2d. im on version 4.2.2. Do you have any fix? edit: i had used = instead of : when declaring vaiable "nav_agent"
Great tutorial. At the end I had to change "@export var nav_agent: NavigationAgent2D" in enemy to "@onready var nav_agent = $Navigation/NavigationAgent2D" since the NavAgent2D was being used as a single resource shared between enemies.
Other than what's shown in this series so far, not yet :/ You could always try making an auto tile for the navigation tiles, and then adding an open margin around the edge. This way you could negate any nav calculations near walls
Dunno if still relevant but for me this worked: 1. Remove the ACCELERATION & FRICTION completely along with the apply_friction & apply_movement 2. Set the func move(): as below: func move(): axis = get_input_axis() velocity = axis * SPEED move_and_slide() So in the end my player control is basically this & it also made the controls feel less being on ice: extends CharacterBody2D @export var SPEED = 600.0 # How fast the player will move (px/s) @onready var axis = Vector2.ZERO func _physics_process(delta): move() func get_input_axis(): axis = Input.get_vector("move_left", "move_right", "move_up", "move_down") axis.x = int(Input.is_action_pressed("move_right")) - int(Input.is_action_pressed("move_left")) axis.y = int(Input.is_action_pressed("move_down")) - int(Input.is_action_pressed("move_up")) return axis.normalized() func move(): axis = get_input_axis() velocity = axis * SPEED move_and_slide()
It works fine with 2 enemies, but when you have 4 or more, then they get stuck on one another. So you are in a situation where 2 enemies are attacking you and 5 are stuck behind them and don't know how to path around each other. How would you solve this?
my enemes walk through trees which have physics layers. my tress are on "tree" layer of terrain and my grass is on "grass" layer. my grass has a navigation layer, but when i add trees, they dont remove the navigation layer. do i have to manually place non navigational grass under my tree?? or is there any other way around this.
@@aleksanderkap3792 i sadly moved on from that project, pixel art was way too time consuming and i moved onto 3d. made a human model in less than a day, took me almost 4 hours to make one walking animation for my 2d characters :( i dont code anymore either until i have a minimum amount of art assets to work with for my game. but i do remember i found a solution, but with everything you fix, some else seems to break, it wasnt working perfectly the way i wanted but it was decent.
Checkout this more updated tutorial on some additional pathfinding methods and tips! th-cam.com/video/1-f4WEy0GBg/w-d-xo.html
I was just about to comment that for some reason it isn't working now. I looked through to documentation but can't seem to see what is different. I literally chose the wrong time to finally do this tutorial lol.
@@jSnakeChips i have been stuck on this subject too i feel like there are no video resources explaining this for 4.1
I dunno, everything does work as it should for me in 4.1
reading that documentation causes me physical pain, it has to be the least useful documentation I have read for a programming language and my code no work
@@errantalgae what's causing you problem exactly? I generally found Godot docs to be quite good.
I usually don't comment on videos but yours is very clear and undestandable, really well done, keep going!
TH-cam search feature is so bad that even though i am subscribed to your channel and searching with exact words pathfinding enemy etc it did not show me that you have already made a video on this topic and such an advance toturial as well exactly what i was looking for TH-cam algorithm is so bad you deserve more subscriber thank god i was looking at your channel today for relevent or similar video otherwise i would have wasted another day . Your channel cover so many advance topics that no one else in the community does thank you so much
This is one of the best Godot tutorials I've seen since I started to learn. Concise and clear. Good work!
Thanks man, this is one of the best video of the that theme.
I have a similar system for the nav, but am struggling with avoidance, I basically want the enemies to stay off the walls and not slide along them so much. It is a TD hobby project, and I have enemies just lining up whenever there is a corner. Is there a way to "spread them out" when you are letting them navigate?
Concise and well presented. Great job. Keep the content coming!
line 19 and 22 complains about not beeing able to call non static functions on the class navigationagent2d. im on version 4.2.2. Do you have any fix?
edit: i had used = instead of : when declaring vaiable "nav_agent"
Great tutorial. At the end I had to change "@export var nav_agent: NavigationAgent2D" in enemy to "@onready var nav_agent = $Navigation/NavigationAgent2D" since the NavAgent2D was being used as a single resource shared between enemies.
nice catch! I did as well instinctively, and it's good to know I did the right thing))
Yesss! Thank you so much for this video!!
This is great, thank you!
Nice video. Do you have anything on avoiding getting stuck on tilemap edges and corners?
Other than what's shown in this series so far, not yet :/
You could always try making an auto tile for the navigation tiles, and then adding an open margin around the edge. This way you could negate any nav calculations near walls
In the property path_postprocessing, set "Corridorfunnel" to "Edgecentered." It's not a perfect solution but it worked for me :-]
Dunno if still relevant but for me this worked:
1. Remove the ACCELERATION & FRICTION completely along with the apply_friction & apply_movement
2. Set the func move(): as below:
func move():
axis = get_input_axis()
velocity = axis * SPEED
move_and_slide()
So in the end my player control is basically this & it also made the controls feel less being on ice:
extends CharacterBody2D
@export var SPEED = 600.0 # How fast the player will move (px/s)
@onready var axis = Vector2.ZERO
func _physics_process(delta):
move()
func get_input_axis():
axis = Input.get_vector("move_left", "move_right", "move_up", "move_down")
axis.x = int(Input.is_action_pressed("move_right")) - int(Input.is_action_pressed("move_left"))
axis.y = int(Input.is_action_pressed("move_down")) - int(Input.is_action_pressed("move_up"))
return axis.normalized()
func move():
axis = get_input_axis()
velocity = axis * SPEED
move_and_slide()
I’m excited to do this later. Surprised at how small the video length is. 18mins translates to 36mins to 1hour for me lol
YES!! I love the player!
Just, hate my game.
Great content!
hi queble i'm shamus thanks 😍 so much 🥰
It works fine with 2 enemies, but when you have 4 or more, then they get stuck on one another. So you are in a situation where 2 enemies are attacking you and 5 are stuck behind them and don't know how to path around each other. How would you solve this?
Thanks for pointing this out!
I'll work on fixing this and make a part 2
maybe if we put enemies on a layer and then add that layer for navigation?
Thanks!
my enemes walk through trees which have physics layers. my tress are on "tree" layer of terrain and my grass is on "grass" layer. my grass has a navigation layer, but when i add trees, they dont remove the navigation layer. do i have to manually place non navigational grass under my tree?? or is there any other way around this.
have you tried changing collision layers & masks for your trees & enemies?
Did u found solution to this? I am wondering how it works with different layers of tilemap
@@aleksanderkap3792 i sadly moved on from that project, pixel art was way too time consuming and i moved onto 3d. made a human model in less than a day, took me almost 4 hours to make one walking animation for my 2d characters :( i dont code anymore either until i have a minimum amount of art assets to work with for my game.
but i do remember i found a solution, but with everything you fix, some else seems to break, it wasnt working perfectly the way i wanted but it was decent.
Thanks great tuts
Thank you my problem is fixed♥️subs