-
Notifications
You must be signed in to change notification settings - Fork 1
/
TextInteraction.gd
52 lines (45 loc) · 1.03 KB
/
TextInteraction.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class_name TextInteraction extends Node
@export var text : Label3D
@export var interaction : InteractionManager
@export var dur : float
@export var colorvalue_min : float
@export var colorvalue_max : float
var elapsed = 0
var moving = false
var fs1 = true
var fs2 = false
var colorvalue_current = 0.0
var colorvalue_next = 0.0
func _process(delta):
CheckStatus()
LerpOpacity()
func CheckStatus():
if (interaction.activeParent == text):
if (!fs1):
BeginLerp()
fs2 = false
fs1 = true
else:
if (!fs2):
EndLerp()
fs1 = false
fs2 = true
func BeginLerp():
colorvalue_current = text.modulate.r
colorvalue_next = colorvalue_max
elapsed = 0
moving = true
pass
func EndLerp():
colorvalue_current = text.modulate.r
colorvalue_next = colorvalue_min
elapsed = 0
moving = true
pass
func LerpOpacity():
if (moving):
elapsed += get_process_delta_time()
var c = clampf(elapsed / dur, 0.0, 1.0)
var color = lerp(colorvalue_current, colorvalue_next, c)
text.modulate = Color(color, color, color, text.modulate.a)
pass