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.
+1 vote

Hello everyone,

I am trying to move text with a Tween Left and Right by scrolling Horizontally in a scroll container.

The scrolling is hanlded by a tween node like so:


The problem is that different texts require more or less scrolling, so the maximum value of the scroll_horizontal changes dynamically.

That's good and all, but I can't find that value to use it in the tween.

Any idea where or how to find it?

in Engine by (122 points)

1 Answer

+1 vote
Best answer

Answering my own question in case anyone needs it in the future:

The max value of scroll horizontal in a scroll container is not directly accesible.

But we can get it with some simple math.

If this is our node structure:


then we get the max of scroll horizontal with:

var scrollH_max = max(0, Label.rect_size.x - ScrollContainer.rect_size.x)

and of scroll vertical with:

var scrollV_max = max(0, Label.rect_size.y - ScrollContainer.rect_size.y)
by (122 points)
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.