• Home
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
Godot Community

Godot Community

Help . "null instance error" (☍﹏⁰)

Scheduled Pinned Locked Moved Godot Forums
2 Posts 2 Posters 31 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • willwill65pnundefined Offline
    willwill65pnundefined Offline
    willwill65pn
    wrote last edited by
    #1

    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 goes

    Invalid get index 'x' (on base: 'null instance').
    

    Advice? thx

    1 Reply Last reply
    1
  • sepTNundefined Offline
    sepTNundefined Offline
    sepTN
    wrote last edited by
    #2
    @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)
    
    1 Reply Last reply
    0

© 2023 Godot Community
Privacy - Terms - Contact

  • Login

  • Don't have an account? Register

Powered by Godot Community
  • First post
    Last post
0
  • Home
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Login

  • Don't have an account? Register