This repository has been archived on 2020-09-30. You can view files and clone it, but cannot push or open issues or pull requests.
odyssey-old/Actors/Player/Player.gd

22 lines
606 B
GDScript
Executable File

extends KinematicBody2D
const SPEED = 320.0
const EPSILON = 0.1
export var is_controlled = false setget set_is_controlled
func _ready():
$Camera.current = is_controlled
func _physics_process(_delta):
var motion = Vector2(
Input.get_action_strength("ui_right")-Input.get_action_strength("ui_left"),
Input.get_action_strength("ui_down")-Input.get_action_strength("ui_up"))
if motion.length() > EPSILON:
$Sprite/AnimationTree.set("parameters/direction/blend_position", motion)
move_and_slide(motion.clamped(1.0) * SPEED)
func set_is_controlled(val):
is_controlled = val
$Camera.current = val