godot-steering-ai-framework/project/demos/SeekFlee/Player.gd
Francois Belair 5627a5636a Fix demo picker blank scene
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.
2020-02-08 11:44:54 -05:00

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"))