Thank you in advance.
I am trying to implement code into my game for a grappling hook. The code works on its own in the test game provided but I cant seem to get it to work in mine.
The problem is that I reference a variable of a child node in the parent's script but it is null.
Full error is: "Invalid set index 'global_position' (on base: 'null instance') with value of type 'Vector2'.
When it throws the error I notice that the game has NOT loaded the Player, GrappleHook, nor Tip assets into the game
I printed the child node ($Tip) and its null in mine but not in the test code.
I reference the child node like so onready var hookTip = $Tip
The code that throws the error is this func _physics_process(_delta: float) -> void:
hookTip.global_position = tip
.
.
.
In case it matters, heres the node structure of the scene
- Node2d: World
- ...KinematicBody2d: Player
- ......Node2d: GrappleHook
- .........KinematicBody2d: Tip
I have tried looking it up and finding why its happening, but no dice. Im already referencing it with onready so shouldnt the child nodes be loading before it tries to call it in the physics_process?