Help . "null instance error" (☍﹏⁰)
-
what is the actually problem ?
extends CharacterBody3D @onready var joystick = get_node("/Pop/HBoxContainer/Sprite2D/TouchScreenButton") var move = Vector3(0,0,0) func _physics_process(delta): move.x = joystick.x move.z = joystick.y player_movement(delta)
The line "var joystick = ..." is wrong . I google it and it says "null instance error" means Node not found . So the problem is the way of getting path . Try so many times . And can't figure it out .
Sometime it goesInvalid get index 'x' (on base: 'null instance').
Advice? thx
-
@onready var joystick = get_node("/Pop/HBoxContainer/Sprite2D/TouchScreenButton")
The variable joystick isn't instantly ready, so at some point it's null variable, until
get_node
has finished the job. Try doing it like:func _physics_process(delta): if joystick == null: return move.x = joystick.x move.z = joystick.y player_movement(delta)