Expose method from c++ class to be shown in AnimationPlayer "Call Method Track " key frame

Godot Version



How do i expose method from my c++ class to be shown in AnimationPlayer
When i add "Call Method Track " key frame ? from editor ?
Or it can be done only via code ?


I don’t know if this helps but this is how you add method tracks via code:

func add_call_method_track_to_animation(animation: Animation) -> void:
	var track_idx: int = animation.add_track(Animation.TYPE_METHOD)
	animation.track_set_path(track_idx, ".")	# Will look for the methods at this path, relative to the AnimatioPlayer
	var time: float = 1.0 # adds the key 1 seconds into the animation
	var method_name: String = "your_method"
	var arguments: Array = [1, 2]
	animation.track_insert_key(track_idx, time, {"method" : method_name, "args" : arguments})

As you can see, you can use track_set_path to set where it looks for the method, but I don’t use C++ so I don’t know if you can actually use this to solve your issue…