0 votes

I'm using one of the demos (Grid movement) to create a slideshow, where each cell in the grid is a new screen to show, and the Actor simply jumps from cell to cell.

But in the demo the movement of Actor is fast and instant. I need the transition from cell to cell to be smooth, using interpolation and easing. There is a string there that seems to be interpolating the movement of Actor, but in the game it's still sharp.

What should I add or change in the code, to make the Actor interpolate smoothly the movement to target position? I'm stuck.

extends "pawn.gd"

onready var Grid = get_parent()

func _ready():
update_look_direction(Vector2(1, 0))

func _process(delta):
var input_direction = get_input_direction()
if not input_direction:

var target_position = Grid.request_move(self, input_direction)
if target_position:

func get_input_direction():
return Vector2(
    int(Input.is_action_pressed("ui_right")) - int(Input.is_action_pressed("ui_left")),
    int(Input.is_action_pressed("ui_down")) - int(Input.is_action_pressed("ui_up"))

func update_look_direction(direction):
$Pivot/Sprite.rotation = direction.angle()

func move_to(target_position):

# Move the node to the target cell instantly,
# and animate the sprite moving from the start to the target cell
var move_direction = (target_position - position).normalized()
$Tween.interpolate_property($Pivot, "position", - move_direction * 32, Vector2(), $AnimationPlayer.current_animation_length, Tween.TRANS_LINEAR, Tween.EASE_IN)
position = target_position


# Stop the function execution until the animation finished
yield($AnimationPlayer, "animation_finished")


func bump():
yield($AnimationPlayer, "animation_finished")
in Engine by (53 points)
edited by

Duplicate of this question.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.