godot-steering-ai-framework/project/demos/Face/FaceDemo.gd
Răzvan C. Rădulescu 1a37b2bee0 Update project to follow GDScript guidelines closer
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.
2020-01-16 10:44:44 +02:00

64 lines
1.4 KiB
GDScript

extends Node2D
onready var player := $Player
onready var gui := $GUI
onready var turret := $Turret
export(int, 0, 359) var max_angular_speed := 90 setget set_max_angular_speed
export(int, 0, 359) var max_angular_accel := 5 setget set_max_angular_accel
export(int, 0, 180) var align_tolerance := 5 setget set_align_tolerance
export(int, 0, 359) var deceleration_radius := 45 setget set_deceleration_radius
export(float, 0, 1000) var player_speed := 600.0 setget set_player_speed
func _ready() -> void:
player.speed = player_speed
turret.setup(
player.agent,
deg2rad(align_tolerance),
deg2rad(deceleration_radius),
deg2rad(max_angular_accel),
deg2rad(max_angular_speed)
)
func set_align_tolerance(value: int) -> void:
if not is_inside_tree():
return
align_tolerance = value
turret.face.alignment_tolerance = deg2rad(value)
func set_deceleration_radius(value: int) -> void:
if not is_inside_tree():
return
deceleration_radius = value
turret.face.deceleration_radius = deg2rad(value)
func set_max_angular_accel(value: int) -> void:
if not is_inside_tree():
return
max_angular_accel = value
turret.agent.max_angular_acceleration = deg2rad(value)
func set_max_angular_speed(value: int) -> void:
if not is_inside_tree():
return
max_angular_speed = value
turret.agent.max_angular_speed = deg2rad(value)
func set_player_speed(value: float) -> void:
if not is_inside_tree():
return
player_speed = value
player.speed = player_speed