The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

I'm working on a simple application that shows a list of controls. When a new control gets added to the list I want to make it look like it grows vertically. I created a tween for rect_size.y but it doesn't work.

Tweening rect_size.x works just fine but when I try to make it grow/shrink vertically it doesn't do anything.

I assume it could be because the items get added to a VBoxContainer and the container somehow prevents changing the height of the items.

Is there anything I can do to make this work?

Here is the my tweening function, it gets called when the control enters the scene

func grow():
    in_tween.interpolate_property(self, "rect_size:y", 0 , rect_size.y, 1.5, Tween.TRANS_LINEAR, Tween.EASE_OUT)
    var end_color = Color(1.0, 1.0, 1.0, 1.0)
    var start_color = Color(1.0, 1.0, 1.0, 0.0)
    in_tween.interpolate_property(self, "modulate", start_color, end_color, 0.5, Tween.TRANS_LINEAR, Tween.EASE_IN)
    if not in_tween.is_active():
        in_tween.start()
Godot version 3.2.3
in Engine by (24 points)

With the last two lines, you don't start the tweening if one is already running. Could it be that you're tween us already running for another node? Make sure the tweening is starting.

I doubt that's the case since it works when I chance rect_size.y to x and the color transition plays regardless.

1 Answer

+1 vote
Best answer

Ok! I've tested in a small project and I think I've found an answer.

I put a label as a child of a VBoxContainer with a style to see it clearly. If I use your technique, which is tweening the size of the rect, from 0 to its original size, it only works in X. The tweening doesn't work on size because inside a VBoxContainer you can't directly change the y size of a node.

But if you tween the scale from 0 to 1, it works in x or y. The tweening is now:

in_tween.interpolate_property(self, "rect_scale:y", 0 , 1, 1.5, 
    Tween.TRANS_LINEAR, Tween.EASE_OUT)

Correct me if I'm wrong but I think it gives the result you're expecting!

by (643 points)
selected by

Yes, it works. It looks a bit weird because the content gets distorted but it basically does what it should. I suspected it's due to the parent being ha VBoxContainer. Thanks, i didn't think of using scale.

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.