![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Malbec |
My character moves slowly from side to side (ignore the cat, it’s an example of the real cat), I recently got into godot, here is my script:
extends KinematicBody2D
var screen_size
export var speed = 900
func _ready():
screen_size = get_viewport_rect().size
func _process(delta):
var velocity = Vector2 (0,0)
if Input.is_action_pressed("move_right"):
velocity.x += speed * delta
if Input.is_action_pressed("move_left"):
velocity.x -= speed * delta
if Input.is_action_pressed("move_up"):
velocity.y -= speed * delta
if Input.is_action_pressed("move_down"):
velocity.y += speed * delta
move_and_collide(velocity * delta)