Guest User

Untitled

a guest
Jan 22nd, 2025
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. func set_ending_animation(animation_name):
  2. if not animation_player:
  3. print("Error: AnimationPlayer not found.")
  4. return
  5.  
  6. var animation = animation_player.get_animation(animation_name)
  7. if not animation:
  8. print("Error: Animation " + animation_name + " not found.")
  9. return
  10.  
  11. # Remove existing method tracks that match the path
  12. for i in range(animation.get_track_count() - 1, -1, -1): # Iterate in reverse to safely remove tracks
  13. if animation.track_get_type(i) == Animation.TYPE_METHOD and animation.track_get_path(i) == get_path():
  14. animation.remove_track(i)
  15. print("Existing method track removed.")
  16.  
  17. # Add the method track
  18. var method_track_index = animation.add_track(Animation.TYPE_METHOD)
  19. if method_track_index < 0:
  20. print("Error: Failed to add method track.")
  21. return
  22.  
  23. var method_path = get_path()
  24. animation.track_set_path(method_track_index, method_path)
  25.  
  26. # Insert the key to call 'toggle_closeup_window' at the desired time
  27. var animation_length = animation.length - 0.05
  28. if animation_length <= 0:
  29. print("Error: Invalid animation length.")
  30. return
  31.  
  32. var call_data = {"method": "toggle_closeup_window", "args": ["False"]}
  33. animation.track_insert_key(method_track_index, animation_length, call_data)
  34. print("Successfully set method track on ", name ,' to call toggle_closeup_window '," at time: ", animation_length)
  35.  
  36. func set_sitting_idle():
  37. if not animation_player:
  38. print("Error: AnimationPlayer not found.")
  39. return
  40.  
  41. var animation_name = "Sitting-Idle_loop"
  42. var animation = animation_player.get_animation(animation_name)
  43. if not animation:
  44. print("Error: Animation 'Sitting-Idle_loop' not found.")
  45. return
  46.  
  47. # Check if the method track already exists
  48. for i in range(animation.get_track_count()):
  49. if animation.track_get_type(i) == Animation.TYPE_METHOD and animation.track_get_path(i) == get_path():
  50. print("Method track for 'Sitting-Idle_loop' already exists. Skipping.")
  51. return
  52.  
  53. # Add the method track
  54. var method_track_index = animation.add_track(Animation.TYPE_METHOD)
  55. if method_track_index < 0:
  56. print("Error: Failed to add method track.")
  57. return
  58.  
  59. var method_path = get_path()
  60. animation.track_set_path(method_track_index, "")
  61.  
  62. # Insert the key to call 'play_hazel_random_animation' at the desired time
  63. var animation_length = animation.length - 0.05
  64. if animation_length <= 0:
  65. print("Error: Invalid animation length.")
  66. return
  67.  
  68. var call_data = {"method": "play_hazel_random_animation", "args": []} # Empty args if no arguments
  69. animation.track_insert_key(method_track_index, animation_length, call_data)
  70. print("Successfully set method track to call 'play_hazel_random_animation' at time: ", animation_length)
Advertisement
Add Comment
Please, Sign In to add comment