1
0
Fork 0
space-capture/scripts/util.gd
2024-08-07 19:56:30 +02:00

10 lines
501 B
GDScript

class_name Util
## Time-independent damping with exponential-decay.
##
## [smoothing] is the proportion of [current] remaining after one second, the
## rest is [target]. [delta_time] represents the number of seconds passed since
## last invocation.
static func damp(current: Variant, target: Variant, smoothing: float, delta_time: float) -> Variant :
# https://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
return lerp(current, target, 1. - pow(smoothing, delta_time))