I found next to no documentation regarding to how to animate using gdscipt:
In my script file I create a StaticBody3D and add that as child, then I try to create an animation to get that rotating around Y axis - but its not working, despite any values in the Quaternion
var animation = Animation.new()
var track_index = animation.add_track(Animation.TYPE_ROTATION_3D)
var q = Quaternion(0, PI, 0, 0)
animation.track_set_path(track_index, ".")
animation.rotation_track_insert_key(track_index, 1, q)
animation.loop_mode = Animation.LOOP_LINEAR
animation.step = 0.1
var player = AnimationPlayer.new()
var anim_library = AnimationLibrary.new()
anim_library.add_animation('rotate', animation)
player.add_animation_library("alib", anim_library)
player.set_name('AnimPlayer')
add_child(player)
player.play('rotate')
… the animation just not do anything. The object is wont move on screen. There are no errors.
If you use print(player.get_animation_list()) you will notice that the animation’s name is actually alib/rotate. If you fix that, you will also get errors because (0, PI, 0, 0) is not a valid rotation - try var q = Quaternion.from_euler(Vector3(0, PI * 0.25, 0)) instead to see an effect.
(I’m using Godot 4.3, so if I said anything not applicable to you, I apologise.)