Hello this is a noob question, so I want the character to move based on the text in the textEdit

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

I can move an object if i typed right, but im just using .move_local_x. I wanted to make the movement soft because i will be making it an animated sprite.
this is my code as of now

extends KinematicBody2D

onready var text = $TextEdit
onready var object = $Sprite

func _on_Button_pressed():
get_input()

var speed = 250
var velocity = Vector2()

func get_input():
# Detect up/down/left/right keystate and only move when pressed.
velocity = Vector2()
if text.text == “right”:
object.velocity.x += 1

velocity = velocity.normalized() * speed

func _physics_process(delta):
get_input()
move_and_collide(velocity * delta)

:bust_in_silhouette: Reply From: aXu_AP

To smoothen movement you need to raise the speed over a longer period.
For example have speed and max_speed variables. speed starts at 0, but when input is detected it will be rised by delta*1000 each frame until max_speed is reached. If no input, substract from speed until it gets to 0.