mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2025-02-03 22:45:55 +01:00
27 lines
906 B
GDScript3
27 lines
906 B
GDScript3
|
extends Reference
|
||
|
class_name GSAISteeringBehavior
|
||
|
|
||
|
# Base class for all steering behaviors.
|
||
|
#
|
||
|
# Steering behaviors calculate the linear and the angular acceleration to be
|
||
|
# to the agent that owns them.
|
||
|
#
|
||
|
# The `calculate_steering` function is the entry point for all behaviors.
|
||
|
# Individual steering behaviors encapsulate the steering logic.
|
||
|
# @category - Base types
|
||
|
|
||
|
# If `false`, all calculations return zero amounts of acceleration.
|
||
|
var is_enabled : bool = true
|
||
|
# The AI agent on which the steering behavior bases its calculations.
|
||
|
var agent : GSAISteeringAgent
|
||
|
|
||
|
# Sets the `acceleration` with the behavior's desired amount of acceleration.
|
||
|
func calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
||
|
if is_enabled:
|
||
|
call("_calculate_steering", acceleration)
|
||
|
else:
|
||
|
acceleration.set_zero()
|
||
|
|
||
|
func _calculate_steering(acceleration: GSAITargetAcceleration) -> void:
|
||
|
acceleration.set_zero()
|