Interactions now differ depending on action type defined in Item resource.

main
Martin Felis 2024-09-30 18:02:20 +02:00
parent 921a8c1eff
commit c187a2aacc
8 changed files with 82 additions and 18 deletions

View File

@ -1,11 +1,54 @@
[gd_scene load_steps=15 format=3 uid="uid://dy8vjf760prhq"]
[gd_scene load_steps=24 format=3 uid="uid://dy8vjf760prhq"]
[ext_resource type="PackedScene" uid="uid://c0ot1kp5fekqy" path="res://assets/3rdparty/KayKit_Adventurers_1.0_EXTRA/Characters/gltf/Rogue.glb" id="1_rsxsi"]
[ext_resource type="AnimationLibrary" uid="uid://dbaynxuqbkor6" path="res://assets/characters/rogue_animation_library.tres" id="2_18sv4"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_fe868"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_duxpv"]
animation = &"rogue/1H_Melee_Attack_Chop"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_njp2v"]
animation = &"rogue/1H_Melee_Attack_Slice_Diagonal"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_go27t"]
animation = &"rogue/Unarmed_Melee_Attack_Kick"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_glihl"]
advance_mode = 2
advance_condition = &"tool_action_chop"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_qm71c"]
priority = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_t6she"]
advance_mode = 2
advance_condition = &"tool_action_slice"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_oq6xv"]
reset = false
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_5ovo5"]
reset = false
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_kjkqd"]
reset = false
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_bqf2d"]
states/Start/position = Vector2(142, 162)
states/rogue_1H_Melee_Attack_Chop/node = SubResource("AnimationNodeAnimation_duxpv")
states/rogue_1H_Melee_Attack_Chop/position = Vector2(490, 58)
states/rogue_1H_Melee_Attack_Slice_Diagonal/node = SubResource("AnimationNodeAnimation_njp2v")
states/rogue_1H_Melee_Attack_Slice_Diagonal/position = Vector2(480, 162)
states/rogue_Unarmed_Melee_Attack_Kick/node = SubResource("AnimationNodeAnimation_go27t")
states/rogue_Unarmed_Melee_Attack_Kick/position = Vector2(485, 257)
transitions = ["Start", "rogue_1H_Melee_Attack_Chop", SubResource("AnimationNodeStateMachineTransition_glihl"), "Start", "rogue_Unarmed_Melee_Attack_Kick", SubResource("AnimationNodeStateMachineTransition_qm71c"), "Start", "rogue_1H_Melee_Attack_Slice_Diagonal", SubResource("AnimationNodeStateMachineTransition_t6she"), "rogue_1H_Melee_Attack_Chop", "End", SubResource("AnimationNodeStateMachineTransition_oq6xv"), "rogue_Unarmed_Melee_Attack_Kick", "End", SubResource("AnimationNodeStateMachineTransition_5ovo5"), "rogue_1H_Melee_Attack_Slice_Diagonal", "End", SubResource("AnimationNodeStateMachineTransition_kjkqd")]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_dqt6d"]
animation = &"rogue/Idle"
@ -25,14 +68,6 @@ node_connections = [&"TimeScale", 0, &"Animation", &"output", 0, &"TimeScale"]
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_ryaua"]
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_1dwt2"]
advance_mode = 2
advance_condition = &"attack"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_w1i70"]
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_chmuj"]
xfade_time = 0.1
advance_mode = 2
@ -43,22 +78,31 @@ xfade_time = 0.1
advance_mode = 2
advance_condition = &"idle"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_2nd5h"]
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_7j7mm"]
xfade_time = 0.1
advance_mode = 2
advance_condition = &"interact"
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_6s34y"]
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_g3yva"]
xfade_time = 0.2
advance_mode = 2
advance_condition = &"running"
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_h0y4b"]
states/End/position = Vector2(902, 102)
states/Interact/node = SubResource("AnimationNodeStateMachine_bqf2d")
states/Interact/position = Vector2(694, 123)
states/Start/position = Vector2(189, 123)
states/rogue_1H_Melee_Attack_Chop/node = SubResource("AnimationNodeAnimation_fe868")
states/rogue_1H_Melee_Attack_Chop/position = Vector2(677, 123)
states/rogue_Idle/node = SubResource("AnimationNodeAnimation_dqt6d")
states/rogue_Idle/position = Vector2(422, 123)
states/running/node = SubResource("AnimationNodeBlendTree_uc6vu")
states/running/position = Vector2(422, 285)
transitions = ["Start", "rogue_Idle", SubResource("AnimationNodeStateMachineTransition_ryaua"), "rogue_Idle", "rogue_1H_Melee_Attack_Chop", SubResource("AnimationNodeStateMachineTransition_1dwt2"), "rogue_1H_Melee_Attack_Chop", "rogue_Idle", SubResource("AnimationNodeStateMachineTransition_w1i70"), "rogue_Idle", "running", SubResource("AnimationNodeStateMachineTransition_chmuj"), "running", "rogue_Idle", SubResource("AnimationNodeStateMachineTransition_oa1w1"), "rogue_1H_Melee_Attack_Chop", "running", SubResource("AnimationNodeStateMachineTransition_2nd5h")]
graph_offset = Vector2(-12, -72)
transitions = ["Start", "rogue_Idle", SubResource("AnimationNodeStateMachineTransition_ryaua"), "rogue_Idle", "running", SubResource("AnimationNodeStateMachineTransition_chmuj"), "running", "rogue_Idle", SubResource("AnimationNodeStateMachineTransition_oa1w1"), "rogue_Idle", "Interact", SubResource("AnimationNodeStateMachineTransition_7j7mm"), "Interact", "rogue_Idle", SubResource("AnimationNodeStateMachineTransition_6s34y"), "Interact", "running", SubResource("AnimationNodeStateMachineTransition_g3yva")]
graph_offset = Vector2(-12, 57.7514)
[node name="Rogue" type="Node3D"]
@ -72,9 +116,14 @@ libraries = {
[node name="AnimationTree" type="AnimationTree" parent="."]
root_node = NodePath("../Rogue")
libraries = {
"rogue": ExtResource("2_18sv4")
}
tree_root = SubResource("AnimationNodeStateMachine_h0y4b")
anim_player = NodePath("../AnimationPlayer")
parameters/conditions/attack = false
parameters/conditions/idle = false
parameters/conditions/interact = false
parameters/conditions/running = false
parameters/Interact/conditions/tool_action_chop = false
parameters/Interact/conditions/tool_action_slice = false
parameters/running/TimeScale/scale = 1.5

View File

@ -12,3 +12,4 @@ icon = ExtResource("1_dlqed")
max_stack_size = 1
is_tool = true
is_buildable = false
tool_action = 1

View File

@ -12,3 +12,4 @@ icon = ExtResource("1_afk8v")
max_stack_size = 1
is_tool = true
is_buildable = false
tool_action = 2

View File

@ -12,3 +12,4 @@ icon = ExtResource("1_gprhx")
max_stack_size = 1
is_tool = true
is_buildable = false
tool_action = 2

View File

@ -12,3 +12,5 @@ scene = ExtResource("2_8uss6")
icon = ExtResource("1_b5epx")
max_stack_size = 1
is_tool = true
is_buildable = false
tool_action = 1

View File

@ -7,3 +7,4 @@ extends Resource
@export var max_stack_size:int = 1
@export var is_tool:bool = false
@export var is_buildable:bool = false
@export_enum("None", "Chop", "Slice") var tool_action: int = 0

View File

@ -24,7 +24,7 @@ signal trigger_message(message:String)
var interaction_state:bool = false
func _process(_delta):
animation_tree.set("parameters/conditions/attack", interaction_state)
animation_tree.set("parameters/conditions/interact", interaction_state)
if interaction_state:
interaction_state = false
@ -82,6 +82,15 @@ func set_right_hand_item(item:Item) -> void:
right_hand_attachement.add_child(item.scene.instantiate())
current_tool = item
animation_tree.set("parameters/Interact/conditions/tool_action_slice", false)
animation_tree.set("parameters/Interact/conditions/tool_action_chop", false)
match item.tool_action:
1:
animation_tree.set("parameters/Interact/conditions/tool_action_chop", true)
2:
animation_tree.set("parameters/Interact/conditions/tool_action_slice", true)
func has_build_tool_active() -> bool:
if current_tool and current_tool.name == "Pickaxe":
return true

View File

@ -32,7 +32,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.470516, 0)
shape = SubResource("CapsuleShape3D_7kfad")
[node name="RightHandBone" type="BoneAttachment3D" parent="."]
transform = Transform3D(-0.000803348, -0.063443, 0.394936, 0.399985, -0.00336239, 0.000273371, 0.00327666, 0.394922, 0.0634475, -0.196151, 0.251476, 0.0431326)
transform = Transform3D(-0.00015721, -0.0606496, 0.395375, 0.399999, -0.000666146, 5.67707e-05, 0.000649959, 0.395375, 0.0606499, -0.196425, 0.255346, 0.0425267)
bone_name = "Knife"
bone_idx = 17
use_external_skeleton = true