Indeed, to access your RichTextLabel, you have load it in a variable by using its path.
You have two options to do so:
- RichTextLabel is a child of KinematicBody2D object, then you can use the notion:
- RichTextLabel is not a child, then you have to access it via
get_node; in this case, you have to go up the tree, find the parent of your RichTextLabel and specify the full path to it.
Let's say you have a scene structure like this:
To get RichTextLabel from KinematicBody2D, you will have to do:
var rtl : RichTextLabel = get_node("../../ui/layout/column/RichTextLabel")
You have to up to the root node by using ../../
Once there, you get the deepest parent of RichTextLabel and go down the tree until you reach RichTextLabel.
It's a standard way to navigate in a tree in computers, ../ meaning go up one level in the tree.
To change the text of RichTextLabel, you will have to turn your variables into text. For instance:
rtl.text = "velocity: " + str(velocity)
I hope this will help you :)