Topic was automatically imported from the old Question2Answer platform.
Asked By
stella3321
Im trying to have the progress bar only show up when an item is picked up by the player, my issue is that the progress bar just doesn’t show up on the screen at all, even after the item is picked up.
Its visible if I take the self.hide() and self.show() out, so the issue is with those specific lines of code.
I’ve also tried self.visible = false and self.visible = true instead but same issue
any help is appreciated
By the way, to format code over multiple lines, don’t use the ‘`’ symbol, use 4 spaces at the start of a line (and an additional 4 space for each indent) to format many lines of code
The bug lies in you onitempickup function. The first line of the function will display the progress bar by calling self.show(), however, your function then calls the _ready function, which calls the self.hide() function.
Removing the _ready call in the onitempickup function will solve the bug
But if I dont have the _ready then the bar will not show any ‘progress’. Like, it wont show that an item has been picked up. Is there a way for me to have to bar hidden at the beginning and then show up when an item has been picked up without removing _ready?
stella3321 | 2023-05-29 20:48
In my opinion it’s bad practice to call _ready from other functions, since your code could get messy. The engine calls _ready for you when the scene enters the scene tree I beleive, so you should try and design your logic around that.
In any case, I think removing _ready and replacing it with $Itemprogress/itembar.value = Items in your onitempickup function should do the trick