godot-steering-ai-framework/project/demos/seek_and_flee/Player.gd
Francois Belair 0e95c24c7f Add GDQuest theme to improved Pursue demo
Changed text boxes to sliders to improve usability. This also involved
adding some simple graphics, since the _draw method is not
anti-aliased and doesn't look great.
2020-01-13 16:15:44 -05:00

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: = 150.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)