Script Effect
Create a Label
node and print out all variables of a certain GameObject
on the Label
node every frame.
Note: Additionally demonstrate how to print out the speed of the game object var v = prototype_player.velocity
.
Key Points
- This script should be attached to a standalone
Control
node. - The path to
prototype_player
needs to be modified according to the actual node of your game object. variable_settings
needs to be specified to the name of your actual variable settings node (some people might have modified this name 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