Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func set_ending_animation(animation_name):
- if not animation_player:
- print("Error: AnimationPlayer not found.")
- return
- var animation = animation_player.get_animation(animation_name)
- if not animation:
- print("Error: Animation " + animation_name + " not found.")
- return
- # Remove existing method tracks that match the path
- for i in range(animation.get_track_count() - 1, -1, -1): # Iterate in reverse to safely remove tracks
- if animation.track_get_type(i) == Animation.TYPE_METHOD and animation.track_get_path(i) == get_path():
- animation.remove_track(i)
- print("Existing method track removed.")
- # Add the method track
- var method_track_index = animation.add_track(Animation.TYPE_METHOD)
- if method_track_index < 0:
- print("Error: Failed to add method track.")
- return
- var method_path = get_path()
- animation.track_set_path(method_track_index, method_path)
- # Insert the key to call 'toggle_closeup_window' at the desired time
- var animation_length = animation.length - 0.05
- if animation_length <= 0:
- print("Error: Invalid animation length.")
- return
- var call_data = {"method": "toggle_closeup_window", "args": ["False"]}
- animation.track_insert_key(method_track_index, animation_length, call_data)
- print("Successfully set method track on ", name ,' to call toggle_closeup_window '," at time: ", animation_length)
- func set_sitting_idle():
- if not animation_player:
- print("Error: AnimationPlayer not found.")
- return
- var animation_name = "Sitting-Idle_loop"
- var animation = animation_player.get_animation(animation_name)
- if not animation:
- print("Error: Animation 'Sitting-Idle_loop' not found.")
- return
- # Check if the method track already exists
- for i in range(animation.get_track_count()):
- if animation.track_get_type(i) == Animation.TYPE_METHOD and animation.track_get_path(i) == get_path():
- print("Method track for 'Sitting-Idle_loop' already exists. Skipping.")
- return
- # Add the method track
- var method_track_index = animation.add_track(Animation.TYPE_METHOD)
- if method_track_index < 0:
- print("Error: Failed to add method track.")
- return
- var method_path = get_path()
- animation.track_set_path(method_track_index, "")
- # Insert the key to call 'play_hazel_random_animation' at the desired time
- var animation_length = animation.length - 0.05
- if animation_length <= 0:
- print("Error: Invalid animation length.")
- return
- var call_data = {"method": "play_hazel_random_animation", "args": []} # Empty args if no arguments
- animation.track_insert_key(method_track_index, animation_length, call_data)
- print("Successfully set method track to call 'play_hazel_random_animation' at time: ", animation_length)
Advertisement
Add Comment
Please, Sign In to add comment