[Godot 2.1] Problem with animationPlayer and sprite modulate

woopdeedoowoopdeedoo Posts: 106Member

I want to animate a sprite to fade out the alpha value of its color, but the color is set through code, and when I'm making the animation I don't know what color that will be. So during gameplay, my animation sets the sprite's color to whatever I set at the start of the animation, instead of using the one the sprite already has.

I thought of using a function track to call get_modulate() from the sprite, but I'm not seeing how I could use that to tell the animation player about the color and apply it to the animation, before playing it...

Anyone has any suggestions?

Answers

  • woopdeedoowoopdeedoo Posts: 106Member
    edited April 29 Answer ✓

    Heh, you know what? Never mind this. It's as simple as giving this to the Call Func track:

    get_animation("fade out sprite").track_set_key_value( 0, 0, get_parent().get_modulate() )
    

    I was thinking you couldn't give it the function's arguments in this way, but it turns out you can! :)

    Though this doesn't quite work as I was expecting. A better option is to animate the Opacity value.

  • kow__kow__ Posts: 24Member

    I know you already found a solution, but another thing you could've done was using a Tween node, and interpolating the modulate property.

Sign In or Register to comment.