mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2024-12-28 09:47:16 +01:00
5627a5636a
It did not have a file path by default, but had an index. Also, the camera on Seek/Flee caused the Go Back button not to show. The scene's been amended and the camera removed, since it wasn't actually useful.
26 lines
665 B
GDScript
26 lines
665 B
GDScript
extends KinematicBody2D
|
|
# Class to control the player in basic left/right up/down movement.
|
|
|
|
|
|
var speed: float
|
|
onready var agent := GSTAgentLocation.new()
|
|
|
|
|
|
func _ready() -> void:
|
|
agent.position = GSTUtils.to_vector3(global_position)
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
var movement := _get_movement()
|
|
if movement.length_squared() < 0.01:
|
|
return
|
|
|
|
move_and_slide(movement * speed)
|
|
agent.position = GSTUtils.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"))
|