how i resolve this

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

attempt to call function 'get_simple_path ’ in base ‘null instance’ on a null instance

:bust_in_silhouette: Reply From: Inces

You lost reference to the node that was calling function getsimplepath. Which means that name before coma in .getsimpath(). Only from your other questions I know that is Navigation node. Most of the times this error happens when given node is not ready at the moment of calling its function (you called getsimplepath too early, before Nav is created and ready ), or user moved this node in scene tree and forgot to change the reference ( You reparented Nav somewhere) .

that is my script, the mensage only appear when i execute the game, i´m reallhy new with this.
(sorry if my english is bad)

extends KinematicBody

onready var nav = $“…/Navigation” as Navigation
onready var player = $“…/player” as KinematicBody

var path = [0]
var current_node = 0
var speed = 2

func _ready():
pass

func _physics_process(delta):
var direction = Vector3()

update_path(player.global_transform.origin)
if current_node < path.size():
		direction = path[current_node] - global_transform.origin
		if direction.length() < 1:
			current_node += 1
else:
	move_and_slide(direction.normalized()* speed) 

func update_path(target_position):
path = nav.get_simple_path(global_transform.origin, target_position)

akaguriookami | 2021-11-16 21:06

So the error refers to this line :

path = nav.getsimplepath(globaltransform.origin, targetposition)

but problem lies here :

onready var nav = $"../Navigation" as Navigation

I see You used String after $, remove quoting interpunction(“”). It propably should be $Navigation if your Navigation is child of scripted node, or get_node(“…/Navigation”) if it is a sibling of scripted node

Inces | 2021-11-17 13:49