diff --git a/scenes/game.tscn b/scenes/game.tscn index 0475d9c..b957030 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -350,7 +350,7 @@ text = "test" transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 3, -4.5) [node name="Dreamer2" parent="." unique_id=1482035031 instance=ExtResource("13_ca42v")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 3, -4.5) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 3, -4.5) [node name="Dreamer3" parent="." unique_id=1936797258 instance=ExtResource("13_ca42v")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 3, -4.5) diff --git a/scenes/living/dreamer_body.tscn b/scenes/living/dreamer_body.tscn index ec09cf0..751ff7d 100644 --- a/scenes/living/dreamer_body.tscn +++ b/scenes/living/dreamer_body.tscn @@ -316,6 +316,106 @@ tracks/7/keys = { "values": [Vector3(0, 0, -1.134464)] } +[sub_resource type="Animation" id="Animation_vo3yb"] +resource_name = "dodge" +length = 0.5 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Body/FrontLeg:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.033333335, 0.1, 0.40000004, 0.46666667), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [Vector3(0.045, -0.09000015, 0), Vector3(0.025, -0.07, 0), Vector3(0.025, 0.05, 0), Vector3(0.025, 0.05, 0), Vector3(0.045, -0.09000015, 0)] +} +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("Body/FrontLeg:rotation") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0, 0.033333335, 0.1, 0.40000004, 0.46666667), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, 0), Vector3(0, 0, 0.05235988), Vector3(0, 0, 0.2617994), Vector3(0, 0, 0.2617994), Vector3(0, 0, 0)] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Body/BackLeg:position") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0, 0.033333335, 0.1, 0.40000004, 0.46666667), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [Vector3(-0.044999994, -0.09000015, 0), Vector3(-0.065, -0.06, 0), Vector3(-0.065, 0.05, 0), Vector3(-0.065, 0.05, 0), Vector3(-0.044999994, -0.09000015, 0)] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Body/BackLeg:rotation") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0, 0.033333335, 0.1, 0.40000004, 0.46666667), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, 0), Vector3(0, 0, 0), Vector3(0, 0, 0.17453292), Vector3(0, 0, 0.17453292), Vector3(0, 0, 0)] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("Body:position") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0, 0.033333335, 0.1, 0.19758424, 0.40000004, 0.46666667), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, 0), Vector3(0, -0.05, 0), Vector3(0, -0.2, 0), Vector3(0, -0.05, 0), Vector3(0, -0.2, 0), Vector3(0, 0, 0)] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("Body:rotation") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0, 0.033333335, 0.1, 0.19844127, 0.31510794, 0.46666667, 0.5151079), +"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, 0), Vector3(0, 0, 0.17453292), Vector3(0, 0, 1.5707964), Vector3(0, 0, 3.1415927), Vector3(0, 0, 4.712389), Vector3(0, 0, 6.2831855), Vector3(0, 0, 6.2831855)] +} +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("Body/ArmPivot/FrontArm:rotation") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0, 0.033333335, 0.46666667), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, 0.08726646), Vector3(0, 0, -0.17453292), Vector3(0, 0, 0.08726646)] +} +tracks/7/type = "value" +tracks/7/imported = false +tracks/7/enabled = true +tracks/7/path = NodePath("Body/ArmPivot/BackArm:rotation") +tracks/7/interp = 1 +tracks/7/loop_wrap = true +tracks/7/keys = { +"times": PackedFloat32Array(0, 0.033333335, 0.46666667), +"transitions": PackedFloat32Array(1, 1, 1), +"update": 0, +"values": [Vector3(0, 0, -0.08726646), Vector3(0, 0, -0.17453292), Vector3(0, 0, -0.08726646)] +} + [sub_resource type="Animation" id="Animation_u5sy4"] resource_name = "fall" length = 0.2 @@ -984,6 +1084,7 @@ _data = { &"RESET": SubResource("Animation_gee14"), &"charge_weapon": SubResource("Animation_lg4u0"), &"dead": SubResource("Animation_imh1v"), +&"dodge": SubResource("Animation_vo3yb"), &"fall": SubResource("Animation_u5sy4"), &"hit": SubResource("Animation_1speq"), &"hold_weapon": SubResource("Animation_yptk5"), @@ -997,6 +1098,9 @@ _data = { [sub_resource type="AnimationNodeAdd2" id="AnimationNodeAdd2_06ej8"] +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_vo3yb"] +animation = &"dodge" + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_vtaks"] animation = &"leap" @@ -1024,12 +1128,16 @@ animation = &"dead" [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_p57ef"] animation = &"jump" +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_lg4u0"] + [sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_1speq"] filter_enabled = true filters = ["Body/ArmPivot:rotation"] [sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_0ul0u"] +[sub_resource type="AnimationNodeOneShot" id="AnimationNodeOneShot_imh1v"] + [sub_resource type="AnimationNodeBlend2" id="AnimationNodeBlend2_gee14"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_u5sy4"] @@ -1063,7 +1171,8 @@ filters = ["Body/ArmPivot:rotation"] [sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_p57ef"] [sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_kvpfn"] -nodes/output/position = Vector2(3580, 40) +graph_offset = Vector2(891.1825, -64.59485) +nodes/output/position = Vector2(4040, 40) nodes/jump/node = SubResource("AnimationNodeOneShot_u5sy4") nodes/jump/position = Vector2(860, 100) nodes/reset/node = SubResource("AnimationNodeAnimation_0tnpc") @@ -1085,13 +1194,13 @@ nodes/fall_anim/position = Vector2(260, 400) nodes/leap/node = SubResource("AnimationNodeBlend2_kvpfn") nodes/leap/position = Vector2(670.4032, 137.15503) nodes/Add2/node = SubResource("AnimationNodeAdd2_06ej8") -nodes/Add2/position = Vector2(3360, 40) +nodes/Add2/position = Vector2(3820, 40) nodes/layering/node = SubResource("AnimationNodeBlend2_ny5xw") -nodes/layering/position = Vector2(3360, 320) +nodes/layering/position = Vector2(3820, 320) "nodes/Animation 3/node" = SubResource("AnimationNodeAnimation_54k0m") -"nodes/Animation 3/position" = Vector2(3100, 400) +"nodes/Animation 3/position" = Vector2(3560, 400) "nodes/Animation 4/node" = SubResource("AnimationNodeAnimation_yptk5") -"nodes/Animation 4/position" = Vector2(3100, 580) +"nodes/Animation 4/position" = Vector2(3560, 580) nodes/hold_weapon/node = SubResource("AnimationNodeBlend2_54k0m") nodes/hold_weapon/position = Vector2(1220, 80) "nodes/Animation 5/node" = SubResource("AnimationNodeAnimation_06ej8") @@ -1105,14 +1214,20 @@ nodes/charge_weapon/position = Vector2(1840, 60) "nodes/Animation 7/node" = SubResource("AnimationNodeAnimation_lg4u0") "nodes/Animation 7/position" = Vector2(1660, 340) nodes/hit/node = SubResource("AnimationNodeBlend2_imh1v") -nodes/hit/position = Vector2(2140, 60) +nodes/hit/position = Vector2(2620, 40) "nodes/Animation 8/node" = SubResource("AnimationNodeAnimation_1speq") -"nodes/Animation 8/position" = Vector2(2000, 300) +"nodes/Animation 8/position" = Vector2(2480, 280) nodes/dead/node = SubResource("AnimationNodeBlend2_0ul0u") -nodes/dead/position = Vector2(2440, 60) +nodes/dead/position = Vector2(2920, 40) "nodes/Animation 9/node" = SubResource("AnimationNodeAnimation_imh1v") -"nodes/Animation 9/position" = Vector2(2280, 320) -node_connections = [&"output", 0, &"Add2", &"jump", 0, &"leap", &"jump", 1, &"Animation", &"walk", 0, &"reset", &"walk", 1, &"walk_speed", &"walk_speed", 0, &"move", &"fall", 0, &"walk", &"fall", 1, &"fall_anim", &"leap", 0, &"fall", &"leap", 1, &"Animation 2", &"Add2", 0, &"dead", &"Add2", 1, &"layering", &"layering", 0, &"Animation 3", &"layering", 1, &"Animation 4", &"hold_weapon", 0, &"jump", &"hold_weapon", 1, &"Animation 5", &"swing_weapon", 0, &"hold_weapon", &"swing_weapon", 1, &"Animation 6", &"charge_weapon", 0, &"swing_weapon", &"charge_weapon", 1, &"Animation 7", &"hit", 0, &"charge_weapon", &"hit", 1, &"Animation 8", &"dead", 0, &"hit", &"dead", 1, &"Animation 9"] +"nodes/Animation 9/position" = Vector2(2760, 300) +nodes/dodge/node = SubResource("AnimationNodeOneShot_imh1v") +nodes/dodge/position = Vector2(2300, 40) +"nodes/Animation 10/node" = SubResource("AnimationNodeAnimation_vo3yb") +"nodes/Animation 10/position" = Vector2(2080, 260) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_lg4u0") +nodes/TimeScale/position = Vector2(2260, 380) +node_connections = [&"output", 0, &"Add2", &"jump", 0, &"leap", &"jump", 1, &"Animation", &"walk", 0, &"reset", &"walk", 1, &"walk_speed", &"walk_speed", 0, &"move", &"fall", 0, &"walk", &"fall", 1, &"fall_anim", &"leap", 0, &"fall", &"leap", 1, &"Animation 2", &"Add2", 0, &"dead", &"Add2", 1, &"layering", &"layering", 0, &"Animation 3", &"layering", 1, &"Animation 4", &"hold_weapon", 0, &"jump", &"hold_weapon", 1, &"Animation 5", &"swing_weapon", 0, &"hold_weapon", &"swing_weapon", 1, &"Animation 6", &"charge_weapon", 0, &"swing_weapon", &"charge_weapon", 1, &"Animation 7", &"hit", 0, &"dodge", &"hit", 1, &"Animation 8", &"dead", 0, &"hit", &"dead", 1, &"Animation 9", &"dodge", 0, &"charge_weapon", &"dodge", 1, &"TimeScale", &"TimeScale", 0, &"Animation 10"] [node name="DreamerBody" type="Node3D" unique_id=723408850] script = ExtResource("1_54k0m") @@ -1192,3 +1307,7 @@ parameters/charge_weapon/internal_active = false parameters/charge_weapon/request = 0 parameters/hit/blend_amount = 0.0 parameters/dead/blend_amount = 0.0 +parameters/dodge/active = false +parameters/dodge/internal_active = false +parameters/dodge/request = 0 +parameters/TimeScale/scale = 1.0 diff --git a/scripts/player.gd b/scripts/player.gd index 7c06b95..be0f55d 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -19,8 +19,22 @@ var swing_timer = 0 var queue_swing = false +var dodging = false +var dodge_timer = 0.0 +var dodge_direction = null + var current_weapon = "basic_sword" +enum { + STATE_NORMAL, + STATE_DODGING, + STATE_ATTACK, + STATE_HIT, + STATE_DEATH +} + +var state = STATE_NORMAL + @onready var game = get_parent() @onready var camera = game.get_node("PlayerCamera") @@ -141,8 +155,16 @@ func _process(delta: float) -> void: combo_timer -= delta if combo_timer <= 0: combo_hits = 0 + + if Input.is_action_just_pressed("dodge") and (not dodging) and (input_dir.length() > 0): + queue_swing = false + dodging = true + dodge_timer = 0.5 + dodge_direction = camera.transform.basis * Vector3(input_dir.x, 0, input_dir.y).normalized() - if Input.is_action_just_pressed("attack") or queue_swing: + $DreamerBody/Animator.set("parameters/dodge/request", AnimationNodeOneShot.ONE_SHOT_REQUEST_FIRE) + + if (Input.is_action_just_pressed("attack") or queue_swing) and (not dodging): if swing_timer > 0: if swing_timer < 0.1: queue_swing = true @@ -237,7 +259,16 @@ func _process(delta: float) -> void: damage_text.get_node("Label").text = str(floor(damage)) var direction = (camera.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() - if direction and (knockback_time <= 0) and (swing_timer <= 0): + if dodging and (knockback_time <= 0): + velocity.x = dodge_direction.x * 6 + velocity.z = dodge_direction.z * 6 + + $DreamerBody/Animator.set("parameters/walk/blend_amount", 0) + + dodge_timer -= delta + if dodge_timer <= 0: dodging = false + + elif direction and (knockback_time <= 0) and (swing_timer <= 0): velocity.x = direction.x * SPEED velocity.z = direction.z * SPEED