mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2025-03-09 07:46:58 +01:00
23 lines
530 B
GDScript3
23 lines
530 B
GDScript3
|
extends KinematicBody2D
|
||
|
|
||
|
|
||
|
var speed: float
|
||
|
|
||
|
onready var agent := GSTAgentLocation.new()
|
||
|
|
||
|
|
||
|
func _physics_process(delta: float) -> void:
|
||
|
var movement := _get_movement()
|
||
|
move_and_slide(movement * speed)
|
||
|
_update_agent()
|
||
|
|
||
|
|
||
|
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"))
|
||
|
|
||
|
|
||
|
func _update_agent() -> void:
|
||
|
agent.position = Vector3(global_position.x, global_position.y, 0)
|