2019-12-16 22:14:46 +01:00
|
|
|
extends KinematicBody2D
|
2020-01-02 23:42:41 +01:00
|
|
|
# Class to control the player in basic left/right up/down movement.
|
2019-12-16 22:14:46 +01:00
|
|
|
|
|
|
|
|
2019-12-19 20:04:08 +01:00
|
|
|
onready var agent: = GSTAgentLocation.new()
|
2019-12-16 22:14:46 +01:00
|
|
|
|
|
|
|
export var speed: = 150.0
|
|
|
|
|
|
|
|
|
|
|
|
func _get_movement() -> Vector2:
|
2019-12-19 20:04:08 +01:00
|
|
|
return Vector2( Input.get_action_strength("sf_right") - Input.get_action_strength("sf_left"),
|
|
|
|
Input.get_action_strength("sf_down") - Input.get_action_strength("sf_up"))
|
2019-12-16 22:14:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
|
|
var movement: = _get_movement()
|
|
|
|
if movement.length_squared() < 0.01:
|
|
|
|
return
|
|
|
|
|
|
|
|
move_and_slide(movement * speed)
|
2019-12-19 20:04:08 +01:00
|
|
|
agent.position = Vector3(global_position.x, global_position.y, 0)
|