I'm new to game dev and I'm making a game kinda like the plants vs zombies zen garden. So I have unlockable pots and the price gets more expensive for every pot that has been bought. The problem is the fact that the richtextlabel doesn't update. it's probably a dumb mistake but I have spent like the last three hours on this. Thanks in advance!
RichTextLabel not updating
You are instancing this node, yes? Is each instance editable and relevant resources made local ensuring their uniqueness? Otherwise you are likely changing every instance at once.
Megalomaniak I'm not instancing this RichTextLabel it's just a permanent child of buypot. The text updates only once at the start then once potprice increases the text doesn't update.
Have you printed the value of potprice to verify that it's changing?
What are the possible values of potunlocked?
What warnings do the yellow triangles indicate?
- Edited
Curious: why is this in _physics_process
? Shouldn't it just be in plain old _process
? You're not doing any physics stuff like position so process may be faster. Also - any debug messages you are getting? Any "standalone expression" errors or anything?
You may also try adding a layer of abstraction. A variable is a reference and if the time of reference is wrong, the code will do the wrong thing.
Try doing a separate variable for the potunlocked * 10, like....
func _process(_delta):
var newPotprice = potunlocked * 10
potprice = newPotprice
$buypot/potcosttext.text = (str(potprice))
DaveTheCoder I have indeed printed the value of potprice to verify that it changes and it does. The possible values of potunlocked is all the way up to 15. The yellow triangles are just indicating that the node has no shape.
SnapCracklins You're right I should just be using _process so I have switched over. I'm not currently getting any debug messages like that. I tried out that code instead of using my old one and it didn't work. The text is still not updating. I figure I will also show you the only time that potunlocked gets added to.
And what is making me more confused is the fact that another RichTextLabel I have does update!
so I'm not sure why this one doesn't wanna update.
Spaghetti_Inc looks like you do exactly what you should not doing kind of waving in quicksand hoping to get out.
To avoid wasting more time on this issue, do a sample project with a single RichTextLabel and a mock-up of your game process. Make it work then, and only then, do the thing you learn in your game, removing any mess you've made in the process.
- Best Answerset by Spaghetti_Inc
JusTiCe8 Thank you! Doing this worked and I figured out that making the potprice a global variable and doing $buypot/potcosttext.text = (str(Global.realpotprice)) in the process function makes it work!