How to use Tweens in Godot
Average Godot Enjoyer
extends Spatial
onready var left_sphere = $Left_Sphere onready var right_sphere = $Right_Sphere onready var blue_sphere = $Moving_Sphere onready var tween = $Tween
func _input(event): if event.is_action_pressed("ui_left"): tween_left()
if event.is_action_pressed("ui_right"): tween_right()
func tween_left(): print("Tweening: Left!")
tween.interpolate_property( blue_sphere, #object to act on "translation", # property on the node we want to manipulate blue_sphere.global_transform.origin, # the place we are starting from left_sphere.global_transform.origin, # the place we are going to 3, # the amount of time in seconds it will taketo get there Tween.TRANS_LINEAR, # the type of transition Tween.EASE_IN_OUT, # the type of easining on the transition 0 # the delay when the tween is started before it moves ) tween.start()
func tween_right(): print("Tweening: Right!") tween.interpolate_property(blue_sphere,"translation",blue_sphere.global_transform.origin,right_sphere.global_transform.origin,3,Tween.TRANS_CUBIC,Tween.EASE_OUT,0) tween.start() ... https://www.youtube.com/watch?v=aKGTXMlyPfM
2172646 Bytes