Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DaddyMonster |
I’ve got a little shader effect - just a sine wave controlling vertex scale so far - and I’ve got a freq
uniform controlling it. I’m using a tween to control this in gdscript.
The obj starts at freq
zero (nothing happening), then tweens to freq
one. When it’s done it fires a signal and tweens back from freq
one to zero:
Here’s the tween subroutine where I send in the start and stop values:
func run_tween(a, b):
printt("freq", mat.get_shader_param("freq"))
var t = $Tween
t.interpolate_property(
mat, "shader_param/freq", a, b, 1,
Tween.TRANS_BOUNCE, Tween.EASE_IN_OUT)
t.start()
Here’s signal method:
func _on_Tween_tween_all_completed():
if not odd_even:
run_tween(1, 0)
printt("freq", mat.get_shader_param("freq"))
odd_even = not odd_even
Obviously I have the odd_even
bool there to go back and forth.
This prints:
freq 0
freq 1
freq 1
freq 0
Except the frequency is visibly speeding up every time you run it. Same duration, quicker sine wave. It even happens when you lerp without easing.
I’m not changing any other values. Am I missing something obvious here?
Sorry, I was being an idiot as usual. The shader had TIME in the sine function which obviously grew over time making the frequency higher. Nothing to do with the tween.
DaddyMonster | 2022-07-23 12:28
Glad you found/fixed the issue - thanks for the follow-up here.
For forum housekeeping, I’d suggest that you copy your comment as an Answer and then select it as Best. That’ll show (on the main board) that the question 1) has an answer and 2) the answer resolved the problem - which is potentially important when searching the forum for help…
jgodfrey | 2022-07-23 14:29
That’s a good idea, let me do that.
DaddyMonster | 2022-07-23 15:26