![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Shadey01 |
I’ve been into programming for around a month now and choose godot as my first engine. At the moment I’m just learning/practicing with random tutuorials I find on the internet. I’ve had a few issues already, but I fixed those with logic combined with trial and error. But I have finally hit a problem I can’t solve.
The raycast which in the code I named “raycast” is supposed to be an onready var variant of RayCastCombat. While this worked for a while after it was written, at some point it just stopped working properly and causes a breakpoint.
The error text reads: Attempt to call function ‘is_colliding’ in base ‘null instance’ on a null instance.
onready var raycast = $"/root/World/Player/Controller/Head/Camera1/RayCastCombat"
func check_collision():
if raycast.is_colliding():
var collider = raycast.get_collider()
if collider.is_in_group("Enemies"):
collider.queue_free()
print("Killed " + collider.name)
I tried using different node paths, but no matter if I used ‘$’ or ‘…/’, the problem is the same.
I’ve watched this tutorial on raycast (The tutorial source code is in the comments):