This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I am currently still working on my long-term project. I would like to know if there is any way to add a dial on top of a progress bar. Similar to the looks of this: https://www.welovesolo.com/slick-slider-progress-bar-with-metal-knob-psd/

Except the know wouldn't be controlled by the mouse. I just wanna know how to get a knob/dial thing to follow the end of the progress bar.

in Engine by (37 points)

1 Answer

0 votes

Example. Create a progress bar and a sprite as children of a node then add this to a script for the sprite:

extends Sprite
func _ready():
    position = get_node("../ProgressBar").get_rect().position


func _process(delta):
    # inc the value of the progress bar
    get_node("../ProgressBar").value += 1
    # set the sprite's x position according to value of the bar:
    # you need to scale 'value according in the following line...
position.x = get_node("../ProgressBar").get_rect().position.x + get_node("../ProgressBar").value

As the comment says, you'll know the x length of the bar so you can calculate a factor to adjust the x position.

by (221 points)

Cool. This works with the standard progress bar, but how would I do this with a TextureProgress? Im getting this: Attempt to call function 'get_rect' in base 'null instance' on a null instance.

Nevermind.
I accidentally made the Sprite the child of the TextureProgress.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.