0 votes

Every tutorial I've seen for PathFollow nodes (both 2D and 3D) says to just change the offset of the PathFollow node to move the node along the path (which should be its parent if I understand correctly). That works when manually changing the value of the offset in the inspector, however when I run the following code:

 public override void _Ready()
        Testing = GetNode<PathFollow>("Path2/Path2Follow");
        Testing.Offset = 0.0f;
public override void _Process(float delta)
            Testing.Offset += OffsetAmt;
            GD.Print($"increase: {Testing.Offset}");

            Testing.Offset -= OffsetAmt;

with the input actions assigned in the project input map (to arrow keys), the print statement says the offset is NaN.
This is my scene setup:
Godot Scene Organizer with the following nodes: A node called main as the main node, a Path node called PathTest with hidden children, a currently invisible Spatial node called Spheres with hidden children, a Spatial node called Spatial with a Camera node as a child,  and a Path node called Path2 with a PathFollow child called Path2Follow which has a MeshInstance child called MeshInstance. The 3D scene is also visible, showing a jagged path with a cube on one of the corners.

Am I missing something or doing something wrong? All I need it to do is be able to move an object along a path (3d) node either backwards or forwards, depending on an input value. Additional information can be given and any help is appreciated.

Godot version v3.3.4
in Engine by (52 points)

1 Answer

0 votes

I deleted my original path node and its children and made new path, pathfollow and meshinstance nodes and adjusted the nodepath in the code and then the code worked as expected. I might refine this project later and upload it to github for others to use.

by (52 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.