mirror of
https://github.com/Relintai/godot-steering-ai-framework.git
synced 2024-11-14 04:57:19 +01:00
31 lines
917 B
GDScript
31 lines
917 B
GDScript
# A desired linear and angular amount of acceleration requested by the steering
|
|
# system.
|
|
# @category - Base types
|
|
extends Reference
|
|
class_name GSAITargetAcceleration
|
|
|
|
# Linear acceleration
|
|
var linear : Vector3 = Vector3.ZERO
|
|
# Angular acceleration
|
|
var angular : float = 0.0
|
|
|
|
# Sets the linear and angular components to 0.
|
|
func set_zero() -> void:
|
|
linear.x = 0.0
|
|
linear.y = 0.0
|
|
linear.z = 0.0
|
|
angular = 0.0
|
|
|
|
# Adds `accel`'s components, multiplied by `scalar`, to this one.
|
|
func add_scaled_accel(accel: GSAITargetAcceleration, scalar: float) -> void:
|
|
linear += accel.linear * scalar
|
|
angular += accel.angular * scalar
|
|
|
|
# Returns the squared magnitude of the linear and angular components.
|
|
func get_magnitude_squared() -> float:
|
|
return linear.length_squared() + angular * angular
|
|
|
|
# Returns the magnitude of the linear and angular components.
|
|
func get_magnitude() -> float:
|
|
return sqrt(get_magnitude_squared())
|