mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2025-02-03 22:45:55 +01:00
1a37b2bee0
Used `var variable := 0.0` as discussed in the Godot issue, instead of `var variable: = 0.0`. Mostly these are minor/cosmetic changes, but I've also reorganized the folder structure (naming of folders) to reflect our guidelines, plus made some minor changes to the demo codes. Still work in progress.
22 lines
606 B
GDScript
22 lines
606 B
GDScript
extends KinematicBody2D
|
|
# Class to control the player in basic left/right up/down movement.
|
|
|
|
|
|
onready var agent := GSTAgentLocation.new()
|
|
|
|
export var speed := 200.0
|
|
|
|
|
|
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 _physics_process(delta: float) -> void:
|
|
var movement := _get_movement()
|
|
if movement.length_squared() < 0.01:
|
|
return
|
|
|
|
move_and_slide(movement * speed)
|
|
agent.position = Vector3(global_position.x, global_position.y, 0)
|