fix AnimationPlayer blending issue in Godot 4.3

I made two sets of changes:

- Not calling AnimationPlayer.play() every frame. It was causing the animation blending to try to apply/retrigger the animation somehow.
- Changed the character model import settings to mark idle and walk animations as looping
pull/19/head
Nathan Lovato 2024-08-17 16:18:15 +07:00
parent 41595b7ff5
commit 78aafa45f3
3 changed files with 46 additions and 59 deletions

@ -24,3 +24,4 @@ transform = Transform3D(1, 0, 0, 0, 0.999999, 0, 0, 0, 0.999999, 0, 0.6, 0)
[node name="AnimationPlayer" parent="." index="1"]
deterministic = true
playback_default_blend_time = 0.2

@ -33,21 +33,6 @@ shape = SubResource("CapsuleShape3D_gdq8c")
[node name="Character" parent="." instance=ExtResource("2_nero3")]
[node name="leg-left" parent="Character/character/root" index="0"]
transform = Transform3D(0.965926, 0, 0.258819, 0, 1, 0, -0.258819, 0, 0.965926, 0.125, 0.17625, -0.02375)
[node name="leg-right" parent="Character/character/root" index="1"]
transform = Transform3D(0.965926, 0, -0.258819, 0, 1, 0, 0.258819, 0, 0.965926, -0.125, 0.17625, -0.02375)
[node name="torso" parent="Character/character/root" index="2"]
transform = Transform3D(1, 0, 0, 0, 0.996194, 0.0871557, 0, -0.0871557, 0.996194, -1.80478e-15, 0.17625, -0.02375)
[node name="arm-left" parent="Character/character/root/torso" index="0"]
transform = Transform3D(0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 0, 0, 1, 0.3, 0.175, 0)
[node name="arm-right" parent="Character/character/root/torso" index="1"]
transform = Transform3D(0.707107, -0.707107, 0, 0.707107, 0.707107, 0, 0, 0, 1, -0.3, 0.1195, 0)
[node name="Shadow" type="Decal" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0)
size = Vector3(1, 2, 1)

@ -81,7 +81,8 @@ func handle_effects(delta):
var horizontal_velocity = Vector2(velocity.x, velocity.z)
var speed_factor = horizontal_velocity.length() / movement_speed / delta
if speed_factor > 0.05:
animation.play("walk", 0.5, speed_factor)
if animation.current_animation != "walk":
animation.play("walk")
if speed_factor > 0.3:
sound_footsteps.stream_paused = false
@ -90,10 +91,10 @@ func handle_effects(delta):
if speed_factor > 0.75:
particles_trail.emitting = true
else:
animation.play("idle", 0.5)
else:
animation.play("jump", 0.5)
elif animation.current_animation != "idle":
animation.play("idle")
elif animation.current_animation != "jump":
animation.play("jump")
# Handle movement input