godot-steering-ai-framework/godot/addons/com.gdquest.godot-steering-.../GSAITargetAcceleration.gd

34 lines
887 B
GDScript3
Raw Normal View History

# A desired linear and angular amount of acceleration requested by the steering
# system.
2020-04-03 02:31:59 +02:00
# @category - Base types
class_name GSAITargetAcceleration
# Linear acceleration
var linear := Vector3.ZERO
# Angular acceleration
var angular := 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
2019-12-21 03:32:21 +01:00
# Adds `accel`'s components, multiplied by `scalar`, to this one.
func add_scaled_accel(accel: GSAITargetAcceleration, scalar: float) -> void:
2019-12-21 03:32:21 +01:00
linear += accel.linear * scalar
angular += accel.angular * scalar
# Returns the squared magnitude of the linear and angular components.
func get_magnitude_squared() -> float:
2019-12-21 03:32:21 +01:00
return linear.length_squared() + angular * angular
# Returns the magnitude of the linear and angular components.
2019-12-21 03:32:21 +01:00
func get_magnitude() -> float:
return sqrt(get_magnitude_squared())