Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | furkan13246578 |
When you enter the character area in godot, the label should increase by +1, but when I use the code below, nothing happens.
extends Area2D
var label = 0
func _on_Area2D_body_entered(body):
if body.name == "Player":
label += 1
It looks like it should work. Have you ut a breakpoint on it to check that line is being reached?
SteveSmith | 2022-11-30 15:39
Cannot see anything wrong with the code you have put here. I would suggest your issue is elsewhere. Its possible that it is a case sensitive issue, for example are you sure you have named your player “Player” and not “player”? this would explain your problem as the label would never increase.
Gluon | 2022-11-30 15:49
You mention a set_text
error in the title… That, coupled with the fact that your variable is named label
makes me think you’re trying to set the text of a label to some value. In the code you posted above, you have a variable named label
that should be incremented when that posted logic is triggered. However, that has nothing to do with displaying that value in a Label
control, if that’s what you’re trying to do.
Bottom line, if the above assumptions are correct, you’re not showing the code where you attempt to set the value of the Label
’s text property…
jgodfrey | 2022-11-30 17:57