I’m new to godot, and to practice in 3D, I’m making a little arcadey flight sim. I couldn’t find any answers for this, though, no matter where I looked.
extends Node3D
@onready var lowpolyfighter = $".."
func _ready():
pass
var tween = get_tree().create_tween()
I have this node, lowpolyfighter, to which this script is linked. It’s a child of a RigidBody3D, which itself is a child of a Node3D. It should be in the scenetree, but it isn’t, and as such it crashes because I’m trying to make a Tween out of something that doesn’t exist. So, what have I done wrong here, and how do I avoid making the same mistake again?
I would just like to clarify that @onready and _ready() are exactly the same. You don’t need to worry about your physics process function referencing the tween because it will never be called before the _ready function.
Just wanted to close this up with something I learned while fixing the rest, it turns out you should not call that tween up there with the var and should instead call it in the function itself. If I’m wrong with this bit of advice, please correct me.