how to transform data to a variable?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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

:bust_in_silhouette: Reply From: Zylann

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