Topic was automatically imported from the old Question2Answer platform.
Asked By
fabio
In unity I used the following script: target = this.gameObject.transform
to capture the transform data of the game (this) object in the target variable.
Can someone give me a hint how to do this in Godot
The equivalent code of what you mentionned is just the fact of putting it in a variable.
Depending on which lifetime you want this variable to have, you may create either a local variable (write var directly inside a function):
func _process(delta):
# Before this line, the variable doesn't exist
var target = self.global_transform
or create a member variable (outside of a function, aka “class scope”).
var target
func _process(delta):
# Before this line, the variable keeps the value it had the last frame (except the first)
target = self.global_transform