![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | OldKalash7 |
Hi, first time posting. I have this problem: My player has a RayCast2d child node and i want to enable it only when my player picks up a weapon from the ground. So the rifle scene is already connected and calls the player function when enters its area. This is the player’s fuction it calls:
func enable_weapon():
print("weapon enabled")
$RayCast2D.set_enabled(true)
The docs state that this is the method for enabling the raycast but i keep getting:
Attempt to call function 'set_enabled' in base 'null instance' on a null instance.
I have searched for solutions but i couldn’t fix it and i’ve been stuck with this for days now. Thanks in advance.
Is the node RayCast2D
accessible from the script? Maybe you accessed the node incorrectly?
Ertain | 2020-09-30 00:35
when I get that error it is because I used either the wrong name or wrong address. did you change the name of the RayCast2d to something else or is the RayCast2D a child of a child in the scene tree?
ArthurER | 2020-09-30 01:03