Script Effect
Creates a Label node and prints all variables of a specific GameObject on every frame of the Label node.
Note: It also demonstrates how to print the velocity of the game object: var v = prototype_player.velocity
Key Points
- This script should be attached to a separate
Controlnode. - The path for
prototype_playermust be modified according to your actual game object node. variable_settingsmust be assigned to the name of your actual variable settings node (some users may have renamed this beforehand).
Core
extends Control
@onready var prototype_player: GameObject = $\"../..\"
@onready var variable_settings: VariableSettings = $\"../../VariableSettings\"
@export var label: Label
func _ready() -> void:
if not label:
print_rich(\"[color=red][b]please assign label![/b][/color]\")
func _process(_delta: float) -> void:
if not label:
return
var v = prototype_player.velocity
var new_text = \"\"
new_text += \"velocity : %s\" % [v]
new_text += \"\\n\"
var all_variables = variable_settings.get_variables()
for i:VariableData in all_variables:
new_text += \"%s: %s \\n\" % [str(i._variable_name),str(i.get_value())]
pass
label.text = new_text