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.

КОМЕНТАРІ • 68

  • @uheartbeast
    @uheartbeast 7 років тому +83

    Excellent tutorial!

    • @blackmoon1534
      @blackmoon1534 3 роки тому

      3 years

    • @anfi8673
      @anfi8673 3 роки тому

      @@blackmoon1534 yea, 3 years

    • @nahomaraya2377
      @nahomaraya2377 3 роки тому

      @@anfi8673 Yeah, 3 years

    • @Switch620
      @Switch620 3 роки тому

      @@nahomaraya2377 Yup, 3 years

    • @xgozulx
      @xgozulx 2 роки тому

      @theBolt yep, so much so that it's 4 now

  • @uwekleen9627
    @uwekleen9627 6 років тому +37

    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!

  • @Any_key404
    @Any_key404 7 років тому +7

    Awesome, something I'll need but haven't used yet.Thanks again for all you do for the Godot community.

  • @aenguspatterson4512
    @aenguspatterson4512 3 роки тому +1

    Please continue this series

    • @Kidscancode
      @Kidscancode  3 роки тому

      Are there particular nodes you are interested in? Also, have you checked out godotrecipes.com/ ?

  • @AlexHoratio
    @AlexHoratio 7 років тому +4

    Definite improvement in delivery from your video on YSort. Great video, keep it up! :)

  • @shaynecrist
    @shaynecrist 7 років тому +10

    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

  • @netmanng
    @netmanng 5 років тому +1

    Very nice tutorial man!. Thank you.

  • @ghostrgp01
    @ghostrgp01 3 роки тому +1

    This was really, really useful, thank you!

  • @garrettwidner8199
    @garrettwidner8199 3 роки тому +1

    Excellent tutorial, thanks!

  • @pelotoncio
    @pelotoncio 4 роки тому +1

    Love the series

  • @TheAquif1990
    @TheAquif1990 3 роки тому +1

    very nice tutorial

  • @ailius1520
    @ailius1520 2 роки тому +1

    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.

  • @dr3x.mp4
    @dr3x.mp4 4 роки тому +2

    thank you so much for this info

  • @habamax
    @habamax 4 роки тому +1

    Amazing! Thank you!

  • @NeilRoy
    @NeilRoy 5 років тому +1

    Well done, thanks.

  • @rodx07max
    @rodx07max 4 роки тому +1

    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

  • @vikrambhavsar3558
    @vikrambhavsar3558 4 роки тому +2

    it's examples like these that should be available on the official Godot website. in written form so that it can br quickly referenced.

  • @jimmervision
    @jimmervision 6 років тому +1

    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?

  • @Nouredyn
    @Nouredyn 2 роки тому +2

    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?

  • @BekaDemuradze
    @BekaDemuradze 4 роки тому +1

    Quick Question, can my follow node jump from one path to another?!

  • @shonyne6532
    @shonyne6532 5 років тому +1

    Thanks You!

  • @Leaphion
    @Leaphion 2 роки тому +1

    Beautiful tutorial! Can I somehow combine two Path2Ds to one?

  • @commentingexistentialcrisi9564
    @commentingexistentialcrisi9564 4 роки тому +1

    how do you use this in coode?

  • @cq7743
    @cq7743 Рік тому

    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

  • @rlplayz6643
    @rlplayz6643 2 роки тому +1

    I am trying to make a 3d car game where an ai car follows a path node but i dont get any curve button

  • @noname85808
    @noname85808 7 років тому +3

    super!

  • @x-seronis-x
    @x-seronis-x 7 років тому +2

    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 ?

    • @Kidscancode
      @Kidscancode  7 років тому +3

      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!

    • @x-seronis-x
      @x-seronis-x 7 років тому

      "RemoteTransform2D", That class name sounds exactly like what I was thinking of above. Cant wait for that video or whichever other you do =-)

  • @dixie_rekd9601
    @dixie_rekd9601 4 роки тому +1

    is there any way to use the path2d node for collisions? I need to create collision between an object and a curve.

    • @Kidscancode
      @Kidscancode  4 роки тому

      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

  • @desoft8b
    @desoft8b 4 роки тому +1

    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.

    • @rajasimon
      @rajasimon 4 роки тому

      It's Mac but don't know the configuration.

    • @sm_stormzy1075
      @sm_stormzy1075 Рік тому

      It depends on the strength of your CPU, and also the optimization of your code.

  • @gibmadaf
    @gibmadaf 4 роки тому +3

    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 !!

    • @Kidscancode
      @Kidscancode  4 роки тому +3

      I have done some stuff on this. See the tutorials here: kidscancode.org/godot_recipes/ai/

    • @gibmadaf
      @gibmadaf 4 роки тому

      @@Kidscancode WOW! what a quick answer !! XD Magnifico I will get to work. Thank you

  • @GermyJer
    @GermyJer 3 роки тому +1

    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?

    • @GermyJer
      @GermyJer 3 роки тому

      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.

    • @Kidscancode
      @Kidscancode  3 роки тому +2

      @@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".

    • @GermyJer
      @GermyJer 3 роки тому

      @@Kidscancode Ah!! Thank you! I'll give that a try.

    • @rlplayz6643
      @rlplayz6643 2 роки тому

      @@Kidscancode was just gonna say that

  • @_misterwhy
    @_misterwhy 6 років тому +1

    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 :)

    • @lincolnpepper816
      @lincolnpepper816 6 років тому

      i assume you just make the path go back to where it started.

    • @Comakino
      @Comakino 5 років тому

      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?

    • @RaptorBot
      @RaptorBot 4 роки тому +1

      turn on loop

  • @neonh3043
    @neonh3043 4 роки тому +1

    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)

    • @Kidscancode
      @Kidscancode  4 роки тому +2

      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.

  • @androidgameplays4every13
    @androidgameplays4every13 4 роки тому +1

    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.

    • @habamax
      @habamax 4 роки тому +1

      It is not equivalent. You constantly add to counter and it grows up very quickly to smth very big that makes glitches for you.

    • @androidgameplays4every13
      @androidgameplays4every13 4 роки тому +1

      @@habamax Isn't the following line adding constantly as well?
      follow.set_offset(follow.get_offset() + 350 * delta)

    • @habamax
      @habamax 4 роки тому

      @@androidgameplays4every13 Well, it does not accumulate but add it to the offset (which might have overflow control, not sure).

    • @habamax
      @habamax 4 роки тому +1

      @@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

    • @androidgameplays4every13
      @androidgameplays4every13 4 роки тому

      I understand now, thank you!