Help with get_node

4.3

hey so can someone tell me how i can reference the ak47 when they are both scenes on their own, but both are in the main scene. because right now i can only get it to reference when i put the ak47 in the actual player scene, which isnt what i want to do

i want the player to be able to reference the ak47 in the script when both are present in the same scene

You can either do it with a @export variable or the parent creates the connections or you use groups

is there any other way i could use to do that? like i want it to be interactable and able to be picked up and stuff like that

Then you would need to use something like a detection-area

Yes you can detect things with has_method
obraz

will do same job get_node("../AK47")

You sure AK47 is sibling ?

1 Like

so i cant use get_node and just able to reference the whole object

If you want a interaction-system its better to use detection-area as they will also allow you to get the whole object but only when you are in range for it

if you expect AK47 to be null and don’t want error use
get_node_or_null and now you can check if AK47 is null.
is better to get nodes in in _ready

sibling of the parent object yes

that worked actually thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.