+1 vote

How does this line of code work?

onready var head = $Head
func physicsprocess(delta):
var headbasis = head.getglobal_transform().basis

Please help

in Engine by (179 points)

1 Answer

0 votes

in the first line you create a variable with the name of "head" that refers to the "Head" node before the scene loads.
in the second line you started the PhysicsProcess(delta) that I'm not sure what it means but what I understand is that it does what's inside it every physics frame.
in the last line you create a variable every physics frame with the name of
"headbasis" that stores the transform(position, rotation, scale) of the head but the basis thing is what I don't understand, I'd like to see the tutorial that you got this code from.
so you basically store the head's transform every physics frame.

by (289 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.