#Label.text not updating when inserting physics related content

5 messages · Page 1 of 1 (latest)

wet grotto
#

Hi, I have a very weird bug. I am trying to show the speed of a RigidBody3D in a Label. But it doesn't work.
Here is the piece of code, which is inside func _physics_process(delta)::

var x = str(round(linear_velocity.length() * 3.6)) # This gives me km/h, if 1 unit is 1 meter.
print(x) # This works
$"../Car/CameraPivot/CanvasLayer/Control/CarPanel/CarSpeedUi/Speed".text = x # This doesn't work
$"../Car/CameraPivot/CanvasLayer/Control/CarPanel/CarSpeedUi/Speed".text = "Example" # This for example works

When I run the game, I get the print output with the speed. But the Label called "Speed" doesn't update.
Now the weird thing: The Label just doesn't update on physics related stuff :
I am using V4.1.1. Does anyone know what I'm doing wrong?

Picture: In the picture you see the Label, which always stays zero, and below the print output, which shows the speed.

gentle lance
wet grotto
# gentle lance What happens if you set it to any other variable ?

Sorry for answering so late,
I tested a bit and found this out.
This works:

$"../Car/CameraPivot/Camera3D/CanvasLayer/Control/CarPanel/CarSpeedUi/Speed".text = str($"../Car/".global_position) # works in console and in Label

This here doesn't:

$"../Car/CameraPivot/Camera3D/CanvasLayer/Control/CarPanel/CarSpeedUi/Speed".text = str(global_position) # works in console and but NOT in Label
#

If I do: linear_velocity.length() it doesn't work, but when I do $"../Car".linear_velocity.length() it works in Label. This seems like a bug

gentle lance