• Godot HelpProgramming
  • Using animation to change button txt color on mouse hover. Want to export color var.

I am using animation player to set up a color fading behavior on mouse hover, and I would like to be able to export the fading color value to be changed from GUI, instead of in the script.

What I have set up so far: https://drive.google.com/file/d/12FFy_GZ3HsLu-QS9DpjwaCuyKwqwJDGY/view?usp=sharing

What I want to do is to export a color variable so that I can set the color value from the Godot GUI. This means that the color value will have to be entered into the last keyframe of the animation. I attached what I have so far, but it did not work.

Is there anyway to achieve this?

Thank you for any help

I'm not sure you can edit a keyframed color in an animation as part of the AnimationPlayer in Godot, at least not easily. What I would recommend is using a Tween node and having it triggered by the animation using a call method track, or even better have a function in your script that is triggered by the animation using a call method track and have that function tell the Tween to change colors. Something like this:

func start_tween_exported_color():
	# you will need to add a Tween node as a child of "Button"
	var tween = get_node("Tween")
	# stop the tween so we can set new properties
	tween.stop_all()
	# Set the color (I'm assuming you are applying the color to the modulate)
	tween.interpolate_property(self, "modulate", 
		Color.white, hoverColor, 1.0, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
	# tell the tween to start
	tween.start()

Then you just need to add a call method track in the AnimationPlayer and have it call start_tween_exported_color on the first frame of the animation.

Also, in the future please refrain from making duplicate posts. Instead, just bump the original post stating you are still having the problem or something similar, as duplicate posting is against forum rules. Thanks!

2 years later