Topic was automatically imported from the old Question2Answer platform.
Asked By
MAxSaL
Hello,
I have been running into an error, which I don’t understand. It crashes my game and it looks like it happens when I try to set the position of an object that is not there. However, before setting the position, I check if the object is there.
func _process(delta):
if carried_object:
carried_object.position = position + $Body.position + Body/CarryPosition.position
The error occurs when I try to set the position of carried_object, and the debugger marks the variable as unoccupied. However, shouldn’t the line, if carried_object: prevent this from happening? I assign carried_object a value in _physics_process.
Idk if there is an easier way to do it? But thats how i fixed the issue
Thanks for your help. However, I have not been able to transfer this concept to my code. carried_object is a node which is spawned in the game. When I tried to re-define the node its movement started lagging… But thanks anyway