![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | rainswell |
Hi all, I think I may just be misunderstanding object oriented principles but if you could help me I would be grateful.
I have a function that I want to pass an empty variable (meant to be an object of some sort), and have the function fill that variable with an object loaded within the function.
I’ve been told here that anything in Godot derived from Object passes by reference. I thought that that would mean I could do this:
onready var test_obj_1 = $test_obj_1
var saved
func _ready():
assign_saved(saved, test_obj_1)
if saved != null:
print("the name of 'saved' is now: " + saved.name)
else:
print("oops, 'saved' is still null.")
pass
func assign_saved(saved_variable : Node, test_object):
saved_variable = test_object
pass
But it seems to print “‘saved’ is still null”. Can anyone tell me what I’m misunderstanding?