Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Mattryan26 |
extends KinematicBody2D
export(int) var speed = 80.0
onready var _animation_player = $AnimationPlayer
func _process(_delta):
if Input.is_action_pressed(“ui_left”):
_animation_player.play(“walkleft”)
else:
_animation_player.stop()
func _physics_process(delta):
var velocity = Vector2.ZERO
if Input.is_action_pressed(“ui_right”):
velocity.x += 1.0
if Input.is_action_pressed(“ui_left”):
velocity.x -= 1.0
if Input.is_action_pressed(“ui_down”):
velocity.y += 1.0
if Input.is_action_pressed(“ui_up”):
velocity.y -= 1.0
move_and_slide(velocity * speed)