0 votes

I have a working scroll container with content. So dragging the scroll bar with the mouse works. But calling the following code:


nothing happens, although printing the "scroll_vertical"-value says:


Why doesn't it scroll to position 55?

Godot version v3.2.3.stable.official
in Engine by (160 points)

1 Answer

0 votes

I've also had some issues using the scroll containers properties. So I kinda did it in a round about way.
If you check on the remote tab during run time and check for your ScrollContainer, you should see a _v_scroll and a _h_scroll added as a child to your ScrollContainer

if you click on _v_scroll and moved the scrollbar using your mice, you'll see that the property "value" of _v_scroll is changing.

In order to set or manipulate the scroll position. You must first access the dynamically created scrollbars generated by ScrollContainer likeso:

var v_scrollbar = $ScrollContainer.get_node("_v_scroll")

then if you want to change its value or make it move or something:

v_scrollbar.value = 100


v_scrollbar.value += 10

I'm still far from the last stages of my UI, but this was how I implemented mine.
Disclaimer: It's far from elegant, but it works.

Here's a sample:
Youtube: Godot ScrollContainer Touch Support and Inertial Scroll

by (334 points)
edited by

Unfortunately your suggestion didn't work. :(
Even changing the values in the remote tab didn't work.

wait that's odd. Could you show the relevant code?
The touch scroll function in my demo uses that same code.

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 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 webmaster@godotengine.org with your username.