I have a mechanic in my game where dust slowly builds up on a window and you have to press a button to clean it, and, I need it to slowly fade away when cleaned. however, if i have the "dustclean" animation just have a modulate with no transparency, it instantly disappears, but if i add a keyframe first where the dust is opaque, if you clean the dust before it becomes fully opaque (because it slowly fades in as it builds up) it suddenly becomes 100% opaque before being wiped away. How would I make it so that the dust fades away starting from whatever level of transparency it was at?
#(SOLVED) How to make a sprite slowly become transparent from the level of transparency it was at
19 messages · Page 1 of 1 (latest)
i have tried to use a tween to get it to work but im struggling with figuring that out
havent gotten that to work
That's an unfortunate limitation of animationPlayer, it only lets you do static animations (from a set point to a set point in a specific time).
Moving to tweens was the right approach as it lets you move to (or from) a dynamic position/value.
I'm guessing you'll want to use something like this in the code (but I'm not 100% sure what you're trying to do lol):
const TIME_TO_CLEAN:float = 1.5
var tween:Tween = create_tween()
tween.tween_property(self, "modulate:a", 0.0, TIME_TO_CLEAN)
#tween.tween_callback(print.bind("ayyy, it finished cleaning"))
in the third line what does 0.0 and time_to_clean do/mean
i get that time to clean = 1.5
basically what are those numbers doing
0.0 is the float value of modulate.a (transparency range from 0.0 -> 1.0)
You can set it with a tween—or other call via string— with "modulate:a" instead of the period call.
In gdscript, press ctrl and then click the method/function "tween_property". It'll take you directly to the documentation and you can see a much better description of everything that is a parameter
oh okyoky
hmmm i used the code but its still not doing anything
wait let me try something
yeah no its still not doing anything
okyoky i think i actually figured something out
thank you for your help!
(SOLVED) How to make a sprite slowly become transparent from the level of transparency it was at
How did you solve it?
i made the animation for the dust fading in a frame based deal so that i could have the modulation key frames be its own thing
so no matter what frame of dustiness it was, the cleaning animation would just lower the modulation