35 lines
867 B
GDScript
35 lines
867 B
GDScript
extends Node
|
|
|
|
# Updated by player
|
|
onready var player = null
|
|
|
|
func vec3_componentwise_clamp(vec: Vector3, lower: float, upper: float) -> Vector3:
|
|
return Vector3(
|
|
clamp(vec.x, lower, upper),
|
|
clamp(vec.y, lower, upper),
|
|
clamp(vec.z, lower, upper)
|
|
)
|
|
|
|
func vec2_xz_to_vec3(xz: Vector2, y: float = 0.0) -> Vector3:
|
|
return Vector3(xz.x, y, xz.y)
|
|
|
|
func vec3_xz(vec: Vector3) -> Vector2:
|
|
return Vector2(vec.x, vec.z)
|
|
|
|
func deactivate_node(node: Node):
|
|
node.set_process(false)
|
|
node.set_physics_process(false)
|
|
node.set_process_input(false)
|
|
|
|
func activate_node(node: Node):
|
|
node.set_process(true)
|
|
node.set_physics_process(true)
|
|
node.set_process_input(true)
|
|
|
|
func clamped_lerp(src: float, dest: float, weight: float, close_enough: float):
|
|
weight = clamp(weight, 0.0, 1.0)
|
|
var v = lerp(src, dest, weight)
|
|
if abs(dest - v) < close_enough:
|
|
return dest
|
|
return v
|