The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+1 vote

attempt to call function 'getsimplepath ' in base 'null instance' on a null instance

Godot version 3.3.4
in Engine by (24 points)
retagged by

1 Answer

0 votes

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) .

by (8,188 points)

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():

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

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

func updatepath(targetposition):
path = nav.getsimplepath(globaltransform.origin, targetposition)

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

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 [email protected] with your username.