Some checks failed
Deploy Promiscuity Auth API / deploy (push) Has been cancelled
Deploy Promiscuity Character API / deploy (push) Has been cancelled
Deploy Promiscuity Crafting API / deploy (push) Has been cancelled
Deploy Promiscuity Inventory API / deploy (push) Has been cancelled
Deploy Promiscuity Locations API / deploy (push) Has been cancelled
Deploy Promiscuity Mail API / deploy (push) Has been cancelled
Deploy Promiscuity World API / deploy (push) Has been cancelled
k8s smoke test / test (push) Has been cancelled
SHIFT + B
42 lines
908 B
GDScript
42 lines
908 B
GDScript
extends Area3D
|
|
|
|
@export var initial_speed := 24.0
|
|
@export var minimum_speed := 4.0
|
|
@export var deceleration := 9.0
|
|
@export var lifetime := 3.0
|
|
|
|
var _direction := Vector3.FORWARD
|
|
var _speed := initial_speed
|
|
var _age := 0.0
|
|
|
|
|
|
func launch(origin: Vector3, direction: Vector3) -> void:
|
|
global_position = origin
|
|
if direction.length() > 0.0001:
|
|
_direction = direction.normalized()
|
|
look_at(global_position + _direction, Vector3.UP)
|
|
_speed = initial_speed
|
|
|
|
|
|
func _ready() -> void:
|
|
body_entered.connect(_on_body_entered)
|
|
area_entered.connect(_on_area_entered)
|
|
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
_age += delta
|
|
if _age >= lifetime:
|
|
queue_free()
|
|
return
|
|
|
|
global_position += _direction * _speed * delta
|
|
_speed = move_toward(_speed, minimum_speed, deceleration * delta)
|
|
|
|
|
|
func _on_body_entered(_body: Node3D) -> void:
|
|
queue_free()
|
|
|
|
|
|
func _on_area_entered(_area: Area3D) -> void:
|
|
queue_free()
|