PathFollow2D, move sprite

Godot Version



I am trying to move the sprite alongside the PathFollow2d node, my current structure is:


I would like to move the Sprite via the created path. I have seen many tutorials, where people move the sprite to the PathFollow2D making it, its child, for me this looks very inconsistent, as I am building a Node2d, with it’s properties, and moving the sprite to the PathFollow2D, just looks architecturaly wrong, as sprite visualizes the Node2d object, and not some seperate entity in PathFollow2D.
How can I achieve the path following, using the structure provided above?

I was thinking of using signals, to send the path from the PathFollow2D to the Sprite, and move it manually in the code, but I supose there should be a better way to achieve this. Thank you in advance.

It looks like Node2d is the top-level node of the entity?

A more common use is to have the Path2D as a child of the space in which it’s moving (like the level), and then have the entity parented to it. This is probably what you’ve seen in tutorials (though the Sprite2D may represent the entirety of the entity for simplicity in tutorials).

Level  (Node2D)
|- Path2D
    |- PathFollow2D
        |- Entity (Node2D)
            |- Sprite2D

However, using the structure you have, you can keep your current hierarchy and give the Sprite2D the transform via a RemoteTransform2D node.

Entity  (Node2D)
|- Sprite2D
|- Path2D
    |- PathFollow2D
        |- RemoteTransform2D (pointing to Sprite2D)

Wow! That is exactly what I needed. Thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.