Attention | Topic was automatically imported from the old Question2Answer platform. | |
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)