- Edited
Ok so i am making a top down 2d game where if you press up you move up and if you press down you move down and so on. This is my code.
extends KinematicBody2D
export (int) var speed = 200
var velocity = Vector2()
func get_input():
velocity = Vector2()
if Input.is_action_pressed("Right"):
velocity.x += 1
if Input.is_action_pressed("Left"):
velocity.x -= 1
if Input.is_action_pressed("Down"):
velocity.y += 1
if Input.is_action_pressed("Up"):
velocity.y -= 1
velocity = velocity.normalized() * speed
Does anybody have any way of making my character face the direction he moves?