abs rotation value of a rotated bone with Skeleton2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By vnmk8

I have a roll animation for my character, it rolls in the ground so i do a 360 degree rotation of the hip bone, at the end of the animation the hip bone stays at 360° rotation and when making the transition to another state such as idle, because in the idle animation the bone is 0° the transition does not flow continuously but rolls back from 360° to 0° making a flip back even though the position is the same how to fix? this with the AnimationPlayerState Machine transitions so is not with code but the solution might be.
Thanks in advance for any answer.

:bust_in_silhouette: Reply From: bluepandion

Maybe you could set the easing value of your last frame (360 degrees) to be as small as possible (0.00001) and add a dummy rotation frame of 0 degrees after that.

Here’s an example scene:

rotation_loop.tscn

[gd_scene load_steps=3 format=2]

[ext_resource path="res://icon.png" type="Texture" id=1]

[sub_resource type="Animation" id=1]
resource_name = "New Anim"
length = 2.0
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Node2D:rotation_degrees")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 1, 2 ),
"transitions": PoolRealArray( 1, 1e-05, 1 ),
"update": 0,
"values": [ 0.0, 360.0, 0.0 ]
}

[node name="Node2D" type="Node2D"]

[node name="Node2D" type="Node2D" parent="."]
position = Vector2( 339.722, 285.905 )

[node name="icon" type="Sprite" parent="Node2D"]
texture = ExtResource( 1 )

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
"anims/New Anim" = SubResource( 1 )

thanks yeah i tought something like that like setting the last frame to 0 rotation but i think there might be a solution and not just a workaround

vnmk8 | 2021-08-03 21:25