brackeys-12/small_wave.gd
2024-09-15 02:15:37 -04:00

29 lines
690 B
GDScript

@tool
extends RichTextEffect
class_name SmallWaveEffect
var bbcode = "smallwave"
func _process_custom_fx(char_fx: CharFXTransform) -> bool:
var time = fmod(char_fx.elapsed_time * 8 - char_fx.relative_index + 100, 10)
var local_time = fmod(time, 1)
if time < 1:
char_fx.offset = Vector2(0, -1 * (sin(local_time * PI)))
if time < 3 or time >= 8:
var color_time = local_time
if time >= 1 and time < 3:
color_time += 1
if time >= 2 and time < 3:
color_time += 1
if time >= 0 and time < 3:
color_time += 1
if time >= 9 or time < 3:
color_time += 1
char_fx.color.a = (sin(color_time / 5 * PI)) * 0.15 + 0.85
else:
char_fx.color.a = 0.85
return true