![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | keidav |
Converting from 3.5.2 to 4.0 and need help on changing two lines of old interpolation code to 4.0 syntax/methods:
@export var move_direction = "Horizontal"
@export var move_distance = 192
@export var speed = 3.0
var move_to = null
var follow = Vector2.ZERO
@onready var platform = $Platform #CharacterBody2D
@onready var tween = create_tween()
func _ready():
if "Horizontal" in move_direction:
move_to = Vector2.RIGHT
elif "Vertical" in move_direction:
move_to = Vector2.UP
move_to *= move_distance
_init_tween()
func _init_tween():
var duration = move_to.length() / float(speed * 128)
tween.interpolate_property(self, "follow", Vector2.ZERO, move_to, duration, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT, IDLE_DURATION)
tween.interpolate_property(self, "follow", move_to, Vector2.ZERO, duration, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT, duration + IDLE_DURATION * 2)
tween.start()
The parameters are vars I have setup and work correctly. The scene is a moving platform that I had working in 3.5.2.