godot_boids/addons/boids/boid_3d/boid_3d.gd

26 lines
624 B
GDScript

extends Node3D
class_name Boid3D
## controls the properties of this boid, deciding how it will behave.
@export var properties: BoidProperties
# position is .position since this is base Node2D
var velocity := Vector3.ZERO
# this is assigned by the flock, if this boid is a child of it
var flock: Flock
var last_processed_in: int = 0
## applies some force to this boid.
func apply_force(force: Vector3) -> void:
velocity += force
velocity = velocity.limit_length(properties.max_speed)
position += velocity
func _get_boid_position() -> Vector3:
return position
func _get_boid_velocity() -> Vector3:
return velocity