diff --git a/spine-godot/example/examples/08-animation-player/animation-player.tscn b/spine-godot/example/examples/08-animation-player/animation-player.tscn index ae21aa9d6..a80618e62 100644 --- a/spine-godot/example/examples/08-animation-player/animation-player.tscn +++ b/spine-godot/example/examples/08-animation-player/animation-player.tscn @@ -36,6 +36,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=85] resource_name = "aim" length = 0.5 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -64,7 +65,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=86] resource_name = "aim_looped" length = 0.5 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -93,6 +93,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=87] resource_name = "death" length = 4.9333 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -121,7 +122,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=88] resource_name = "death_looped" length = 4.9333 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -149,6 +149,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=89] resource_name = "hoverboard" +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -176,7 +177,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=90] resource_name = "hoverboard_looped" -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -205,6 +205,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=91] resource_name = "idle" length = 1.6667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -233,6 +234,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=92] resource_name = "idle-turn" length = 0.2667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -261,7 +263,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=93] resource_name = "idle-turn_looped" length = 0.2667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -290,7 +291,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=94] resource_name = "idle_looped" length = 1.6667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -319,6 +319,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=95] resource_name = "jump" length = 1.3333 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -347,7 +348,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=96] resource_name = "jump_looped" length = 1.3333 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -376,6 +376,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=97] resource_name = "portal" length = 3.1667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -404,7 +405,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=98] resource_name = "portal_looped" length = 3.1667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -433,6 +433,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=99] resource_name = "run" length = 0.6667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -461,6 +462,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=100] resource_name = "run-to-idle" length = 0.2667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -489,7 +491,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=101] resource_name = "run-to-idle_looped" length = 0.2667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -518,7 +519,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=102] resource_name = "run_looped" length = 0.6667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -547,6 +547,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=103] resource_name = "shoot" length = 0.6333 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -575,7 +576,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=104] resource_name = "shoot_looped" length = 0.6333 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -603,6 +603,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=105] resource_name = "walk" +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -630,7 +631,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=106] resource_name = "walk_looped" -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -688,6 +688,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=108] resource_name = "aim" length = 0.5 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -716,7 +717,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=109] resource_name = "aim_looped" length = 0.5 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -745,6 +745,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=110] resource_name = "death" length = 4.9333 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -773,7 +774,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=111] resource_name = "death_looped" length = 4.9333 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -801,6 +801,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=112] resource_name = "hoverboard" +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -828,7 +829,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=113] resource_name = "hoverboard_looped" -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -857,6 +857,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=114] resource_name = "idle" length = 1.6667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -885,6 +886,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=115] resource_name = "idle-turn" length = 0.2667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -913,7 +915,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=116] resource_name = "idle-turn_looped" length = 0.2667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -942,7 +943,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=117] resource_name = "idle_looped" length = 1.6667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -971,6 +971,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=118] resource_name = "jump" length = 1.3333 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -999,7 +1000,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=119] resource_name = "jump_looped" length = 1.3333 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1028,6 +1028,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=120] resource_name = "portal" length = 3.1667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1056,7 +1057,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=121] resource_name = "portal_looped" length = 3.1667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1085,6 +1085,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=122] resource_name = "run" length = 0.6667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1113,6 +1114,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=123] resource_name = "run-to-idle" length = 0.2667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1141,7 +1143,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=124] resource_name = "run-to-idle_looped" length = 0.2667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1170,7 +1171,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=125] resource_name = "run_looped" length = 0.6667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1199,6 +1199,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=126] resource_name = "shoot" length = 0.6333 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1227,7 +1228,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=127] resource_name = "shoot_looped" length = 0.6333 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1255,6 +1255,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=128] resource_name = "walk" +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1282,7 +1283,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=129] resource_name = "walk_looped" -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1340,6 +1340,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=131] resource_name = "gun-grab" length = 0.666667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1368,7 +1369,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=132] resource_name = "gun-grab_looped" length = 0.666667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1397,6 +1397,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=133] resource_name = "gun-holster" length = 0.666667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1425,7 +1426,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=134] resource_name = "gun-holster_looped" length = 0.666667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1454,6 +1454,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=135] resource_name = "jump" length = 1.53333 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1482,7 +1483,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=136] resource_name = "jump_looped" length = 1.53333 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1511,6 +1511,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=137] resource_name = "roar" length = 2.13333 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1539,7 +1540,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=138] resource_name = "roar_looped" length = 2.13333 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1568,6 +1568,7 @@ tracks/1/keys = { [sub_resource type="Animation" id=139] resource_name = "walk" length = 1.26667 +loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1596,7 +1597,6 @@ tracks/1/keys = { [sub_resource type="Animation" id=140] resource_name = "walk_looped" length = 1.26667 -loop = true tracks/0/type = "value" tracks/0/path = NodePath(".:animation_name") tracks/0/interp = 1 @@ -1843,7 +1843,7 @@ tracks/3/keys = { "values": [ 0.5 ] } -[node name="Node2D" type="Node2D"] +[node name="Node2D2" type="Node2D"] script = ExtResource( 2 ) [node name="Spineboy" type="SpineSprite" parent="."] diff --git a/spine-godot/spine_godot/SpineAnimationTrack.cpp b/spine-godot/spine_godot/SpineAnimationTrack.cpp index b69ffa4b5..dd5602d9c 100644 --- a/spine-godot/spine_godot/SpineAnimationTrack.cpp +++ b/spine-godot/spine_godot/SpineAnimationTrack.cpp @@ -216,7 +216,7 @@ Ref SpineAnimationTrack::create_animation(spine::Animation *animation #if VERSION_MAJOR > 3 // animation_ref->set_loop(!loop); #else - animation_ref->set_loop(loop); + animation_ref->set_loop(!loop); #endif animation_ref->set_length(duration); @@ -232,18 +232,17 @@ Ref SpineAnimationTrack::create_animation(spine::Animation *animation } void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite) { + if (track_index < 0) return; sprite = Object::cast_to(variant_sprite); if (!sprite) return; if (!sprite->get_skeleton_data_res().is_valid() || !sprite->get_skeleton_data_res()->is_skeleton_data_loaded()) return; - if (track_index < 0) return; - - AnimationPlayer *animation_player = find_animation_player(); - if (!animation_player) return; - + if (!sprite->get_skeleton().is_valid() || !sprite->get_animation_state().is_valid()) return; spine::AnimationState *animation_state = sprite->get_animation_state()->get_spine_object(); if (!animation_state) return; spine::Skeleton *skeleton = sprite->get_skeleton()->get_spine_object(); if (!skeleton) return; + AnimationPlayer *animation_player = find_animation_player(); + if (!animation_player) return; if (Engine::get_singleton()->is_editor_hint()) { #ifdef TOOLS_ENABLED