mirror of
https://github.com/Relintai/pandemonium_demo_projects.git
synced 2024-12-21 13:56:50 +01:00
27 lines
707 B
GDScript
27 lines
707 B
GDScript
extends KinematicBody2D
|
|
# Class to control the player in basic left/right up/down movement.
|
|
|
|
var speed: float
|
|
onready var agent := GSAIAgentLocation.new()
|
|
|
|
|
|
func _ready() -> void:
|
|
agent.position = GSAIUtils.to_vector3(global_position)
|
|
|
|
|
|
func _physics_process(_delta: float) -> void:
|
|
var movement := _get_movement()
|
|
if movement.length_squared() < 0.01:
|
|
return
|
|
|
|
# warning-ignore:return_value_discarded
|
|
move_and_slide(movement * speed)
|
|
agent.position = GSAIUtils.to_vector3(global_position)
|
|
|
|
|
|
func _get_movement() -> Vector2:
|
|
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")
|
|
)
|