Invalid get index 'unit' (on base: 'PathFollow2D').

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AbhishekL

Hi, I was following through a tutorial, can get past this error.

Here’s the code

extends Node

export (PackedScene) var mob_scene

func _on_MobTimer_timeout():
var mob_spawn_location = $MobPath/MobSpawnLocation
mob_spawn_location.unit.offset = randf()

var mob = mob_scene.instance()
add_child(mob)



var direction = mob_spawn_location.rotation + PI / 2
mob.position = mob_spawn_location.position

direction += rand_range(-PI / 4, PI / 4)
mob.rotation = direction

var velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)
mob.linear_velocity = velocity.rotated(direction)
:bust_in_silhouette: Reply From: jgodfrey

That .unit.offset should be .unit_offset