Godot Engine - Know Your Nodes: PathFollow2D
Вставка
- Опубліковано 22 лип 2024
- "Know Your Nodes" is a series of Godot Game Engine videos where we take a single node type and show how it’s used. Maybe you’ve never come across this particular node before, or maybe you were just wondering what it’s for, but hopefully after this you’ll have a new tool you can use making your own games. This time we'll be demonstrating how to use the PathFollow2D node.
Sample projects from this video can be found here:
github.com/kidscancode/godot_...
Support me on Patreon: / kidscancode
Thanks to github.com/djrm/godot-design for title image.
Excellent tutorial!
3 years
@@blackmoon1534 yea, 3 years
@@anfi8673 Yeah, 3 years
@@nahomaraya2377 Yup, 3 years
@theBolt yep, so much so that it's 4 now
I'm a 52 years old kid :) and I'm a coder and I'm teaching kids at a basic school in programming (Scratch). So I can code (more or less...). What I want to say is that it is a pleasure to watch your tutorial videos! You are making a great job!
Awesome, something I'll need but haven't used yet.Thanks again for all you do for the Godot community.
Please continue this series
Are there particular nodes you are interested in? Also, have you checked out godotrecipes.com/ ?
Definite improvement in delivery from your video on YSort. Great video, keep it up! :)
As someone fairly new to Godot this series will be invaluable to me. The official docs are lacking example usage on a lot of nodes, ItemList for example, and I've hard a hard time finding tutorials that are node specific so I go through a LOT of time with trial and error. Please don't stop with these videos, they are amazingly helpful. My only request is to make them faster! lol
godot doc is the fucking Sahara..
Very nice tutorial man!. Thank you.
This was really, really useful, thank you!
Excellent tutorial, thanks!
Love the series
very nice tutorial
Darn it. It just occurred to me: the cleanest way to get a KinematicBody2D to follow a path and use a lot of these features: Just give it the same script for going to a point, but instead point it at the PathFollow2D.
thank you so much for this info
Amazing! Thank you!
Well done, thanks.
Amazing bro i needed this for real!!!, do u know how to add animations depending on the points the sprite is at? or just animate the sprite while moving thats all i need, thanks man
it's examples like these that should be available on the official Godot website. in written form so that it can br quickly referenced.
I've got a question: how to change paths if i've got multiple instances on a scene (lets say i've created 3 of them and added all of them as a child of a simple Node Container) in a smooth way? I was thinking on making an enemy that chases around a PathFollow node that is moving along a path, but if it changes paths, it should slerp (comming from Unity, bear it with me here) to another follow path... would that work?
When I do this, the path I draw with the Path2D node stays visible in the game screen (in kind of the same blue-ish color as a collision). I can't for the life of me find a way to change this. Any ideas?
Quick Question, can my follow node jump from one path to another?!
Thanks You!
Beautiful tutorial! Can I somehow combine two Path2Ds to one?
how do you use this in coode?
What happens when the pop-up window flickers and minimizes after running a scene, and you need to tap the icon in the taskbar to maximize it (during which the game is running in the background and has sound effects). Then after I manually bring up the window, the game lags and needs to be forced to exit to close
I am trying to make a 3d car game where an ai car follows a path node but i dont get any curve button
super!
Great video. Looking forward to the future ones since I've only been using Godot for a week at this point.
Q: Does this mean if any unit in a game is meant to ever follow a path it will need to have its root be based off PathFollow2d? Or is it simple enough to just have some derived 'PathNightPatrol' / 'PathEscapeRoute' objects that are derived from PathFollow2d that you only temporarily add your units to ?
You could do it that way - when it's "on the path" it's a child of the PathFollow2D, and otherwise it has a different location in the tree. There is also the "RemoteTransform2D" which will let you have one object mirror another's movement. I'm already getting some ideas for a followup topic!
"RemoteTransform2D", That class name sounds exactly like what I was thinking of above. Cant wait for that video or whichever other you do =-)
is there any way to use the path2d node for collisions? I need to create collision between an object and a curve.
Sure - you can pass the curve's points into a CollisionPolygon2D. I do something similar here: ua-cam.com/video/QLZa1mjW-YU/v-deo.html
Hi, thanks for this, now I understand this path2D node.
One question, I have observed that you start really fast when you click on "play scene".
It takes me a lot longer, I guess it's due to the power of the PC.
What PC equipment do you have?.
Sorry for my english.
It's Mac but don't know the configuration.
It depends on the strength of your CPU, and also the optimization of your code.
Hello! I really liked your video! I am making a game on Godot, I am new to this XD and would like to learn. My question is ... imagine that the planes are enemies that follow a path (path) and if the player gets closer, the planes will follow him and if he leaves the vision range, the planes will return to their path.
As much as I seek I find nothing. It would be very interesting to see a tutorial about this
Thank you in advance for your tutorials !!
I have done some stuff on this. See the tutorials here: kidscancode.org/godot_recipes/ai/
@@Kidscancode WOW! what a quick answer !! XD Magnifico I will get to work. Thank you
Really great tutorial! I'm running into a strange issue with Godot in a lot of places where the copy/paste or duplicate function doesn't work as you would think. One of the most surprising of these errors was with this Path2D node. I made a scene of a floating platform with the root node as a Path2D with the intention that i could plop the scene into a level and then change the path for each copy. Unfortunately, no matter what I do I can't seem to get Godot to treat the copies as if they are seperate instances and any changes i apply to the path are applied to all copies. This happens even when I make a local copy of the scene, which I would think would ensure no more connection exist from the original and the copy. Any suggestions?
As an asides this is happening for me in a lot of places: If i duplicate a node i can change the position and a few other properties just fine but things like modulate or text are still connected. In animation player, if i copy and paste an animation and then change the properties of the copy it mirrors those changes on the original as well. VERY frustrating and making me reconsider my choice to go with Godot.
@@GermyJer This is to be expected and is by design. Resources are shared (ie passed by reference) - the path data inside the node is a resource. If you duplicate the node, you'll need to select the path Resource and choose "make unique".
@@Kidscancode Ah!! Thank you! I'll give that a try.
@@Kidscancode was just gonna say that
I'm trying to make an horizontal path, but when my sprite is at the end, I'd like to make it come back (reverse), how to ? Thanks a lot :)
i assume you just make the path go back to where it started.
A little late to the party here but I'm trying to do that too. There must be some simple code to back it up without drawing a new path? You ever figure it out?
turn on loop
Ok i know i am late, so here goes nothing...
How should i add a child to PathFollow2D via code? whenever i try, the child spawns off screen
That part of my code goes like this:
onready var patrol = $"PathFollow2D"
onready var average_guy = preload("res://Enemies/Checkpoint_Enemy.tscn")
var enemy
func _ready():
enemy = average_guy.instance()
enemy.position = get_global_position()
enemy.rotation = 0
patrol.add_child(enemy)
You're setting your enemy's `position` to something far away. A node's `position` is relative to its parent, so set it to (0, 0) and it'll match the path follow's position.
Your following line of code works perfectly
follow.set_offset(follow.get_offset() + 350 * delta)
However my equivalent piece of code doesn't work as well (it glitches badly)
counter += 350
follow.set_offset(counter * delta)
Why? I really can't understand why yours works so well and mine doesn't. Thank you.
It is not equivalent. You constantly add to counter and it grows up very quickly to smth very big that makes glitches for you.
@@habamax Isn't the following line adding constantly as well?
follow.set_offset(follow.get_offset() + 350 * delta)
@@androidgameplays4every13 Well, it does not accumulate but add it to the offset (which might have overflow control, not sure).
@@androidgameplays4every13 basically you set offset to 350*delta, then 700*delta, then 1050*delta... instead of taking current offset which is smth between beginning and ending of a path and adding to it only 350*delta
I understand now, thank you!