Tween a spatial node's global position in 3D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Macryc

I must be forgetting something really basic…

I’m trying to tween the position of a spatial node in 3D along one axis, but cannot get it to work. My code:

extends Spatial

onready var tween_target = $Tween

func _ready():
	tween_target.interpolate_property(self, "translation", self.global_transform.origin.x, self.global_transform.origin.x+20, 3, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
	tween_target.start()
:bust_in_silhouette: Reply From: njamster

Use

tween_target.interpolate_property(self, "translation:x", self.global_transform.origin.x, self.global_transform.origin.x+20, 3, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)

or

tween_target.interpolate_property(self, "translation", self.global_transform.origin, self.global_transform.origin + Vector3(20, 0, 0), 3, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)

With the code you’ve provided, you’re interpolating the value of a three-dimensional vector from a one-dimensional value to another one-dimensional value.

:bust_in_silhouette: Reply From: joekim7

Property name for local position is “translation”
Property name for global position is “global_transform:origin”
I think you may be using the local position property, but you should instead use global position property.