Hello, I'm new to godot and I'm trying to follow a tutorial from DGQuest "Code your first complete 2d game".

In this main script I'm trying to use the node PathFollow2d to spawn mobs. However, when I try setting "unit_offset" or "offsest" to any value, the PathFollow2d.unit_offset stay as 0.

I tried setting it to 0.5 instead of using randf( ) and I also tried using the setter for this property with the set_unit_offset(0.5), but when I run my game my $MobPath/PathFollow2d.position and unit_offsest stay as 0.

I wish I could use this node to spawn my enimies instead of working around it. Can I get any help?

Path's curve must contain some points. Otherwise the offset is meaningless so engine probably just ignores any attempt to set the value.

To test things out try adding two test points prior to setting unit_offset and see if it makes the difference:

$MobPath.curve.add_point(Vector2(0, 0) )
$MobPath.curve.add_point(Vector2(100, 100) )
# now set the offset value

@xyz said: Path's curve must contain some points. Otherwise the offset is meaningless so engine probably just ignores any attempt to set the value.

To test things out try adding two test points prior to setting unit_offset and see if it makes the difference:

$MobPath.curve.add_point(Vector2(0, 0) )
$MobPath.curve.add_point(Vector2(100, 100) )
# now set the offset value

I tested it and it worked. So my problem is with the curve 2d inside the path 2d. I was creating it with the godot graphical interface, I may have done something wrong here while setting up those nodes. I deleted the nodes again and tried creating the curve 2d with the IDE and it worked, thanks!

a year later