et on rajoute un animation node blend tree

et ouai! on est comme ça par ici.
on a suivi un tuto
alors on fait les beaux

https://www.youtube.com/watch?v=iElHZhOxGYA
This commit is contained in:
Thomas
2025-02-21 18:45:04 +01:00
parent bf4bfb9f5a
commit 134759b1b5
2 changed files with 20 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=6 format=3 uid="uid://vclpg4e4ql54"]
[gd_scene load_steps=8 format=3 uid="uid://vclpg4e4ql54"]
[ext_resource type="Script" path="res://caracters/player/player_controler.gd" id="1_oapm5"]
[ext_resource type="AnimationNodeStateMachine" uid="uid://ddr1ltkievtku" path="res://animations/human/human_state_machine.tres" id="3_1y7fn"]
@@ -9,6 +9,16 @@
radius = 5.0
height = 48.0
[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_85jde"]
[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_iwsa7"]
nodes/HumanState/node = ExtResource("3_1y7fn")
nodes/HumanState/position = Vector2(133.333, 120)
nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_85jde")
nodes/TimeScale/position = Vector2(453.333, 53.3333)
nodes/output/position = Vector2(640, 146.667)
node_connections = [&"TimeScale", 0, &"HumanState", &"output", 0, &"TimeScale"]
[node name="CharacterBody2D" type="CharacterBody2D"]
z_index = 100
motion_mode = 1
@@ -26,12 +36,13 @@ rotation = 1.5708
shape = SubResource("CapsuleShape2D_a4vmx")
[node name="AnimationTree" type="AnimationTree" parent="."]
tree_root = ExtResource("3_1y7fn")
tree_root = SubResource("AnimationNodeBlendTree_iwsa7")
advance_expression_base_node = NodePath("..")
anim_player = NodePath("../AnimationPlayer")
parameters/grabing/blend_position = Vector2(0, 0)
parameters/idling/blend_position = Vector2(-0.353287, 0.839053)
parameters/walking/blend_position = Vector2(0, 0)
parameters/HumanState/grabing/blend_position = Vector2(0, 0)
parameters/HumanState/idling/blend_position = Vector2(0, 0)
parameters/HumanState/walking/blend_position = Vector2(0, 0)
parameters/TimeScale/scale = 1.55
[node name="AnimationPlayer" parent="." instance=ExtResource("3_c286j")]

View File

@@ -7,7 +7,7 @@ extends CharacterBody2D
@export var wants_to_grab = false;
@onready var animation_tree := $AnimationTree
@onready var state_machine := animation_tree.get("parameters/playback") as AnimationNodeStateMachinePlayback
@onready var state_machine := animation_tree.get("parameters/HumanState/playback") as AnimationNodeStateMachinePlayback
var last_facing_direction = Vector2(0,-1) # facing south
@@ -19,9 +19,9 @@ func readInputs():
velocity = Input.get_vector("move_left", "move_right", "move_up", "move_down") * speed
func updateFacingDirectionInAnimationTree():
animation_tree.set("parameters/walking/blend_position", last_facing_direction)
animation_tree.set("parameters/idling/blend_position", last_facing_direction)
animation_tree.set("parameters/grabing/blend_position", last_facing_direction)
animation_tree.set("parameters/HumanState/grabing/blend_position", last_facing_direction)
animation_tree.set("parameters/HumanState/idling/blend_position", last_facing_direction)
animation_tree.set("parameters/HumanState/walking/blend_position", last_facing_direction)
func _physics_process(delta):
readInputs()