# oyvTZWUjCy0
main
bel 2025-08-25 22:42:28 -06:00
parent 9c9fd7f91c
commit d8f75b94a0
2 changed files with 39 additions and 23 deletions

View File

@ -16,10 +16,13 @@ func _physics_process(_delta: float) -> void:
new_direction = new_direction.normalized()
velocity = new_direction * speed
if velocity == Vector2.ZERO:
$AnimationTree.get("parameters/playback").travel("idle")
# oyvTZWUjCy0
var moving := velocity != Vector2.ZERO
$AnimationTree["parameters/conditions/moving"] = moving
$AnimationTree["parameters/conditions/not_moving"] = !moving
if !moving:
return
$AnimationTree.set("parameters/walk/blend_position", new_direction)
$AnimationTree.set("parameters/idle/blend_position", new_direction)
$AnimationTree.get("parameters/playback").travel("walk")
move_and_slide()

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=15 format=3 uid="uid://dbhiwig4potyb"]
[gd_scene load_steps=18 format=3 uid="uid://dbhiwig4potyb"]
[ext_resource type="Script" uid="uid://csqcsepu2r0ts" path="res://Entities/Character/character.gd" id="1_a1h5o"]
[ext_resource type="Texture2D" uid="uid://dasxw18q3mppl" path="res://icon.svg" id="1_bmc7m"]
@ -6,24 +6,6 @@
[sub_resource type="RectangleShape2D" id="RectangleShape2D_bmc7m"]
size = Vector2(14.8999, 28.4489)
[sub_resource type="Animation" id="Animation_a1h5o"]
resource_name = "new_animation"
length = 2.00005
loop_mode = 1
step = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Icon:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.01, 0.303333, 0.59, 0.86, 1.15, 1.44, 1.74),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
"update": 1,
"values": [2, 1, 3, 4, 5, 6, 7]
}
[sub_resource type="Animation" id="Animation_xasj2"]
length = 0.5
loop_mode = 1
@ -57,6 +39,24 @@ tracks/0/keys = {
"values": [0]
}
[sub_resource type="Animation" id="Animation_a1h5o"]
resource_name = "new_animation"
length = 2.00005
loop_mode = 1
step = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Icon:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.01, 0.303333, 0.59, 0.86, 1.15, 1.44, 1.74),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
"update": 1,
"values": [2, 1, 3, 4, 5, 6, 7]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_xasj2"]
_data = {
&"RESET": SubResource("Animation_xasj2"),
@ -90,11 +90,23 @@ blend_point_3/node = SubResource("AnimationNodeAnimation_4th1x")
blend_point_3/pos = Vector2(1, 0)
blend_mode = 1
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_a1h5o"]
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_xasj2"]
advance_mode = 2
advance_condition = &"moving"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_6vsl0"]
advance_mode = 2
advance_condition = &"not_moving"
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_roimm"]
states/idle/node = SubResource("AnimationNodeAnimation_a1h5o")
states/idle/position = Vector2(490, 105)
states/walk/node = SubResource("AnimationNodeBlendSpace2D_roimm")
states/walk/position = Vector2(490, 199)
transitions = ["Start", "idle", SubResource("AnimationNodeStateMachineTransition_a1h5o"), "idle", "walk", SubResource("AnimationNodeStateMachineTransition_xasj2"), "walk", "idle", SubResource("AnimationNodeStateMachineTransition_6vsl0")]
[node name="Node2D" type="CharacterBody2D"]
scale = Vector2(1.00672, 0.989311)
@ -105,7 +117,6 @@ position = Vector2(0.566751, -15.3349)
texture = ExtResource("1_bmc7m")
hframes = 6
vframes = 4
frame = 5
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0.496663, -14.0781)
@ -120,4 +131,6 @@ libraries = {
[node name="AnimationTree" type="AnimationTree" parent="."]
tree_root = SubResource("AnimationNodeStateMachine_roimm")
anim_player = NodePath("../AnimationPlayer")
parameters/conditions/moving = false
parameters/conditions/not_moving = false
parameters/walk/blend_position = Vector2(-0.819838, -0.497758)