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. | Twitter

0 votes

Hey there!

I'm trying to tween the offsets property of a gradient but am having trouble doing so. I have two main problems.
1: The offsets property of a gradient texture is a PoolFloatArray and I can't seem to be able to put arrays into the start and end value parameters of the interpolate_property method and a Vector2() doesn't work either.
2: I can't go further into the property to change only a single index of the array (From the data found in the inspector it looks like I should be able to do offsets:indices/0 but an error is thrown instead)

I can use the AnimationPlayer node to animate the offsets property of a gradient, of which the path is texture:gradient:offsets (texture is the texture property of the textureRect I'm using, gradient is the gradient resource I'm using). I notice that the AnimationPlayer node can animate an array without any problems, is there a trick I'm missing to make this work in the Tween node?

I would settle with using the Animation Player node but I can't seem to be able to make the animation line up with the other tweening animations I have already set up (I dunno how to make an EASEINOUT, TRANS_BACK animation in the Animation Player node work).

If you know how to make a tweening animation work with the offsets property of a gradient, or if you know how to make an EASEINOUT, TRANS_BACK animation work in an AnimationPlayer I would love to hear it.

Godot version 3.2.1
in Engine by (71 points)
edited by

The two parameters I am having the most trouble with are supposed to be filled with Variants.

Looking at the docs about variants
I found that Variants can be arrays (found at bottom of page).

However, whenever I use an array (or a PoolFloatArray which is what the property uses) I get this error:

calcdelta_val: Invalid parameter type. Supported types are: bool, int, float, Vector2, Rect2, Vector3, Transform2D, Quat, AABB, Basis, Transform, Color.

Why is this working differently than what the docs details? What am I missing?

Also, I learned that I can replace the initialvalue parameter in interpolateproperty with null which makes this a little bit easier.

1 Answer

+1 vote
Best answer

It is not possible to animate a gradient with Tween at this time. It's also not possible to make a EASE_IN_OUT, TRANS_BACK animation with an AnimationPlayer with just two keyframes since the value exceeds the keyframe values. You'll need four keyframe values and you'll have to play with the easing as well.

by (8,550 points)
selected by

Thanks for the quick reply!

I did some more research after posting this and came to the same conclusion with tweening. I've mentioned that issue on Github as well.

Your response about AnimationPlayer is really helpful and will definitely help me in accomplishing what I want with my game at this time.

Again, thank you.

Alternatively, you create a variable that represents the offset value, tween that property, and then in the _process() function you can call the set_offset() method of the gradient with that property to set the offset manually.

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.