func _ready():
var test = "TestText Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
text = test
var visibleRatio = "RichTextLabel:visible_ratio"
var animation = Animation.new()
animation.set_length(1)
var track_index = animation.add_track(Animation.TYPE_VALUE)
animation.track_set_path(track_index, visibleRatio)
animation.track_insert_key(track_index, 0, 0)
animation.track_insert_key(track_index, 1, 1)
var lib = AnimationLibrary.new()
lib.add_animation("start",animation)
var pAnim = AnimationPlayer.new()
pAnim.add_animation_library("textanims",lib)
pAnim.play("textanims/start")
I’m new to Godot.
I’m trying to get the text to appear smoothly but it doesn’t show up at all. I’ve looked all over for tutorial and such but everything i found is outdated.
I’ve worked around the problem like this.
I don’t know if this is the best solution(probably not).
func _ready():
text = "TestText Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
var charPsec = 1.0
var lent = (get_total_character_count()*1.0) / charPsec
var animation = Animation.new()
animation.set_length(lent)
animation.add_track(Animation.TYPE_VALUE)
animation.track_set_path(0, "%RichTextLabel:visible_ratio")
animation.track_insert_key(0, 0, 0)
for x in range(get_total_character_count()):
animation.track_insert_key(0, (1 / charPsec)*x , x / (get_total_character_count()*1.0))
print((1 / charPsec)*x ," ", x / (get_total_character_count()*1.0))
var lib = AnimationLibrary.new()
lib.add_animation("start",animation)
$AnimationPlayer.add_animation_library("textanims",lib)
$AnimationPlayer.play("textanims/start")
I can set the speed by modifying charPsec .
Currently it’s 1 character/second.