feat: animations and AI adjustments&sweep attack

This commit is contained in:
Sara Gerretsen 2026-03-15 23:04:27 +01:00
parent 10056bb847
commit bdb767e723
23 changed files with 4228 additions and 43 deletions

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -24,4 +24,3 @@ script = SubResource("GDScript_nmc1l")
script = ExtResource("1_kltr5")
anim_name = "stagger_high"
face_target = 30.0
blend = 0.03

View file

@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://blpbabfwxdvfr"]
[ext_resource type="Script" uid="uid://yhqui7k36cuo" path="res://behaviours/check_attack_possible.gd" id="1_kk63v"]
[ext_resource type="Script" uid="uid://yhqui7k36cuo" path="res://behaviours/check_jab_requested.gd" id="1_kk63v"]
[ext_resource type="Script" uid="uid://ywfmsbsdc6s7" path="res://behaviours/select_target.gd" id="2_tlqqd"]
[ext_resource type="Script" uid="uid://bp4utstetxnhr" path="res://behaviours/animate.gd" id="3_4aw38"]

View file

@ -3,7 +3,4 @@ extends BehaviourAction
@onready var body := get_behaviour_tree().get_parent() as CharacterBody3D
func _enter() -> int:
if body.attack_possible():
return Success
else:
return Fail
return Success if body.wants_jab_attack() else Fail

View file

@ -0,0 +1,6 @@
extends BehaviourAction
@onready var body := get_behaviour_tree().get_parent() as CharacterBody3D
func _enter() -> int:
return Success if body.wants_sweep_attack() else Fail

View file

@ -0,0 +1 @@
uid://bqoruvny8r5ox

View file

@ -19,7 +19,11 @@ func _enter() -> int:
resource_name = "RepeatForever"
script/source = "extends BehaviourAction
func _enter() -> int: return Running
@onready var body := get_behaviour_tree().get_parent() as Node
func _enter() -> int:
body.set_process_mode(Node.PROCESS_MODE_DISABLED)
return Running
func _execute() -> int: return Running
"
@ -96,6 +100,9 @@ script = SubResource("GDScript_1fc8h")
[node name="SequenceHitHigh" parent="BehaviourRepeater/BehaviourSelector" unique_id=1573780476 instance=ExtResource("1_jqoh2")]
[node name="StaggerHighAnim" parent="BehaviourRepeater/BehaviourSelector/SequenceHitHigh" index="1" unique_id=809148281]
blend = 0.02
[node name="Wait" type="BehaviourAction" parent="BehaviourRepeater/BehaviourSelector/SequenceHitHigh" unique_id=481327400]
script = SubResource("GDScript_xqvpn")

View file

@ -2,6 +2,9 @@
[ext_resource type="PackedScene" uid="uid://cpedp17gycei5" path="res://behaviours/branches/sequence_hit_high.tscn" id="1_frs2a"]
[ext_resource type="PackedScene" uid="uid://blpbabfwxdvfr" path="res://behaviours/branches/sequence_jab_chain.tscn" id="2_lj7kj"]
[ext_resource type="Script" uid="uid://bqoruvny8r5ox" path="res://behaviours/check_sweep_requested.gd" id="3_67pab"]
[ext_resource type="Script" uid="uid://ywfmsbsdc6s7" path="res://behaviours/select_target.gd" id="3_frs2a"]
[ext_resource type="Script" uid="uid://bp4utstetxnhr" path="res://behaviours/animate.gd" id="4_ssybv"]
[sub_resource type="GDScript" id="GDScript_ykyjo"]
resource_name = "PlayerMovement"
@ -44,7 +47,6 @@ script/source = "extends BehaviourAction
func _enter() -> int:
anim.play(\"ready_unarmed\", .1)
body.velocity = Vector3()
return Success
"
@ -58,6 +60,21 @@ func _enter() -> int:
[node name="SequenceJabChain" parent="BehaviourRepeater/BehaviourSelector" unique_id=376452224 instance=ExtResource("2_lj7kj")]
[node name="BehaviourSequence" type="BehaviourSequence" parent="BehaviourRepeater/BehaviourSelector" unique_id=300422952]
[node name="BehaviourAction" type="BehaviourAction" parent="BehaviourRepeater/BehaviourSelector/BehaviourSequence" unique_id=513519372]
script = ExtResource("3_67pab")
[node name="BehaviourAlwaysSuccess" type="BehaviourAlwaysSuccess" parent="BehaviourRepeater/BehaviourSelector/BehaviourSequence" unique_id=646381584]
[node name="SelectTarget" type="BehaviourAction" parent="BehaviourRepeater/BehaviourSelector/BehaviourSequence/BehaviourAlwaysSuccess" unique_id=351779860]
script = ExtResource("3_frs2a")
[node name="PlaySweep" type="BehaviourAction" parent="BehaviourRepeater/BehaviourSelector/BehaviourSequence" unique_id=79582133]
script = ExtResource("4_ssybv")
anim_name = "sweep"
face_target = 20.0
[node name="Movement" type="BehaviourAction" parent="BehaviourRepeater/BehaviourSelector" unique_id=532637433]
script = SubResource("GDScript_ykyjo")

View file

@ -13,9 +13,8 @@ signal damaged(amount : int, source : Node3D)
@export var health : int = 6
var hurt_high : bool = false
@onready var anim := %AnimationPlayer as AnimationPlayer
var hurt_high : bool = false
var target : Node3D = null
func _ready():
@ -29,12 +28,13 @@ func _damaged(amount : int, source : Node3D):
func _physics_process(delta : float):
var motion := anim.get_root_motion_position()
velocity = (motion.x * global_basis.x + motion.z * global_basis.z) / delta
velocity += get_gravity() * delta
move_and_slide()
func find_targets() -> Array[Node3D]:
return $AwarenessArea.aware
func attack_possible() -> bool:
func wants_jab_attack() -> bool:
return target and target.global_position.distance_to(global_position) < 1.5
"
@ -42,24 +42,24 @@ func attack_possible() -> bool:
albedo_color = Color(0.36862746, 0.5686275, 1, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_we7g8"]
size = Vector3(0.33496094, 0.23144531, 0.26367188)
size = Vector3(0.33496094, 0.5253906, 0.26367188)
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_882u1"]
radius = 0.33984375
radius = 0.2133789
[sub_resource type="CylinderShape3D" id="CylinderShape3D_we7g8"]
height = 1.296875
radius = 5.7021484
[node name="bot" unique_id=250133973 groups=["EnemyHitbox"] instance=ExtResource("1_882u1")]
[node name="bot" unique_id=49523271 groups=["EnemyHitbox"] instance=ExtResource("1_882u1")]
collision_layer = 2
collision_mask = 3
script = SubResource("GDScript_882u1")
[node name="Mesh" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(706042794) index="0" unique_id=1499137314]
[node name="Mesh" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(1548948889) index="0" unique_id=1839254735]
material_override = SubResource("StandardMaterial3D_41oev")
[node name="HandR" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(706042794) index="1" unique_id=957498611]
[node name="HandR" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(1548948889) index="1" unique_id=957498611]
transform = Transform3D(0.015967373, -0.083946444, 0.9963424, -0.17989334, -0.98045003, -0.07972447, 0.9835564, -0.17796235, -0.030756809, 0.27221423, 0.7951686, 0.024477992)
bone_name = "hand.r"
bone_idx = 10
@ -74,11 +74,11 @@ source = NodePath("../../../..")
damage_group = "PlayerHitbox"
[node name="CollisionShape3D" type="CollisionShape3D" parent="Character/Skeleton3D/HandR/DamageAreaR" index="0" unique_id=1459089003]
transform = Transform3D(1.0000031, -3.5762787e-07, 1.4210855e-14, -1.1920929e-07, 1.0000023, -1.49011585e-08, -5.5879497e-09, 4.917384e-07, 1, 9.4322706e-05, 0.101888776, -0.010492921)
transform = Transform3D(1.0000031, -4.61936e-07, -9.126961e-08, -1.1920929e-07, 1.0000024, 1.8626451e-09, -7.4505806e-08, 4.703179e-07, 1, 9.433925e-05, 0.10188866, -0.010492891)
shape = SubResource("BoxShape3D_we7g8")
debug_color = Color(0.9966913, 0, 0.17880186, 1)
[node name="HandL" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(706042794) index="2" unique_id=1761081841]
[node name="HandL" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(1548948889) index="2" unique_id=1761081841]
transform = Transform3D(-0.039434362, 0.07924447, -0.9960749, 0.12679999, -0.9883944, -0.083653376, -0.99114394, -0.12960118, 0.028928574, -0.2710728, 0.7714727, 0.0945672)
bone_name = "hand.l"
bone_idx = 7
@ -97,7 +97,7 @@ transform = Transform3D(1.0000169, -1.5795231e-06, -3.874302e-07, 8.046627e-07,
shape = SubResource("BoxShape3D_we7g8")
debug_color = Color(0.9966913, 0, 0.17880186, 1)
[node name="AnimationPlayer" parent="." index="1" unique_id=445797329]
[node name="AnimationPlayer" parent="." index="1" unique_id=245226940]
unique_name_in_owner = true
root_motion_track = NodePath("Character/Skeleton3D:root")

View file

@ -10,7 +10,8 @@ script/source = "extends CharacterBody3D
signal damaged(amount : int, source : Node3D)
var attack_queued : bool = false
var jab_queued : bool = false
var sweep_queued : bool = false
var hurt_high : bool = false
var target : Node3D = null
@ -23,12 +24,19 @@ func _damaged(_amount : int, source : Node3D):
func _physics_process(delta: float):
var root_velocity : Vector3 = %AnimationPlayer.get_root_motion_position() / delta
velocity = (global_basis.x * root_velocity.x + global_basis.z * root_velocity.z)
var y_velocity := velocity.y
velocity = global_basis.x * root_velocity.x + global_basis.z * root_velocity.z
velocity.y = y_velocity
if not is_on_floor():
velocity += get_gravity() * delta
move_and_slide()
func _unhandled_input(event : InputEvent):
if event.is_action_pressed(\"jab\"):
attack_queued = true
jab_queued = true
get_viewport().set_input_as_handled()
elif event.is_action_pressed(\"sweep\"):
sweep_queued = true
get_viewport().set_input_as_handled()
func is_valid_target(node : Node3D) -> bool:
@ -37,21 +45,30 @@ func is_valid_target(node : Node3D) -> bool:
func find_targets() -> Array[Node3D]:
return $AwarenessArea.aware.filter(is_valid_target)
func attack_possible() -> bool:
if attack_queued:
attack_queued = false
func wants_jab_attack() -> bool:
if jab_queued:
jab_queued = false
return true
return false
func wants_sweep_attack() -> bool:
if sweep_queued:
sweep_queued = false
return true
return false
"
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_eqqp1"]
radius = 0.30371094
radius = 0.21240234
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_f46kd"]
albedo_color = Color(0.8666667, 0.22352941, 0.41568628, 1)
[sub_resource type="BoxShape3D" id="BoxShape3D_uxov2"]
size = Vector3(0.33496094, 0.19042969, 0.26367188)
size = Vector3(0.33496094, 0.6435547, 0.26367188)
[sub_resource type="BoxShape3D" id="BoxShape3D_nmc1l"]
size = Vector3(0.33496094, 0.8294678, 0.4711914)
[sub_resource type="GDScript" id="GDScript_nmc1l"]
resource_name = "CameraPivot"
@ -77,7 +94,7 @@ func _process(_delta):
[sub_resource type="SphereShape3D" id="SphereShape3D_nmc1l"]
radius = 0.3
[node name="bot" unique_id=1726366668 groups=["PlayerHitbox"] instance=ExtResource("1_eqqp1")]
[node name="bot" unique_id=162481247 groups=["PlayerHitbox"] instance=ExtResource("1_eqqp1")]
collision_layer = 2
collision_mask = 3
script = SubResource("GDScript_eqqp1")
@ -93,10 +110,10 @@ debug_color = Color(0, 0.6, 0.69803923, 1)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.0963671, 0)
target_group = "EnemyHitbox"
[node name="Mesh" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(1931156214) index="0" unique_id=613701145]
[node name="Mesh" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(937444697) index="0" unique_id=1897762821]
material_override = SubResource("StandardMaterial3D_f46kd")
[node name="HandR" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(1931156214) index="1" unique_id=385862689]
[node name="HandR" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(937444697) index="1" unique_id=385862689]
transform = Transform3D(0.015967373, -0.083946444, 0.9963424, -0.17989334, -0.98045003, -0.07972447, 0.9835564, -0.17796235, -0.030756809, 0.27221423, 0.7951686, 0.024477992)
bone_name = "hand.r"
bone_idx = 10
@ -110,11 +127,11 @@ script = ExtResource("4_nmc1l")
source = NodePath("../../../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Character/Skeleton3D/HandR/DamageAreaR" index="0" unique_id=580766922]
transform = Transform3D(1.0000031, -4.61936e-07, -8.940697e-08, -1.1920929e-07, 1.0000024, 1.3969839e-09, -7.264316e-08, 4.703179e-07, 1, 9.433925e-05, 0.10188866, -0.010492891)
transform = Transform3D(1.0000031, -4.6193608e-07, -8.9406996e-08, -1.1920928e-07, 1.0000017, -3.5762787e-07, -7.264316e-08, 4.3213376e-07, 0.99999887, 9.4339266e-05, 0.10188866, -0.010492921)
shape = SubResource("BoxShape3D_uxov2")
debug_color = Color(0.9966913, 0, 0.17880186, 1)
[node name="HandL" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(1931156214) index="2" unique_id=279793409]
[node name="HandL" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(937444697) index="2" unique_id=279793409]
transform = Transform3D(-0.039434362, 0.07924447, -0.9960749, 0.12679999, -0.9883944, -0.083653376, -0.99114394, -0.12960118, 0.028928574, -0.2710728, 0.7714727, 0.0945672)
bone_name = "hand.l"
bone_idx = 7
@ -132,7 +149,25 @@ transform = Transform3D(1.0000169, -1.5944242e-06, -4.04194e-07, 6.556511e-07, 1
shape = SubResource("BoxShape3D_uxov2")
debug_color = Color(0.9966913, 0, 0.17880186, 1)
[node name="AnimationPlayer" parent="." index="4" unique_id=951425454]
[node name="LegR" type="BoneAttachment3D" parent="Character/Skeleton3D" parent_id_path=PackedInt32Array(937444697) index="3" unique_id=2088257762]
transform = Transform3D(0.9947343, 0.10095803, 0.017639676, 0.10222586, -0.98967797, -0.1004331, 0.0073180734, 0.1017075, -0.9947873, 0.14436838, 0.42896914, -0.076926425)
bone_name = "leg.lower.r"
bone_idx = 14
[node name="DamageAreaLegR" type="Area3D" parent="Character/Skeleton3D/LegR" index="0" unique_id=744767490 node_paths=PackedStringArray("source")]
collision_layer = 0
collision_mask = 2
monitoring = false
monitorable = false
script = ExtResource("4_nmc1l")
source = NodePath("../../../..")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Character/Skeleton3D/LegR/DamageAreaLegR" index="0" unique_id=836699763]
transform = Transform3D(1.0000174, -1.6069971e-06, -1.4901161e-07, 5.9604645e-07, 1.000027, -2.0861623e-07, 1.0579823e-06, 1.0393561e-06, 1.0000147, -4.7951937e-05, 0.19483443, -0.114048116)
shape = SubResource("BoxShape3D_nmc1l")
debug_color = Color(0.9966913, 0, 0.17880186, 1)
[node name="AnimationPlayer" parent="." index="4" unique_id=2139879921]
unique_name_in_owner = true
root_motion_track = NodePath("Character/Skeleton3D:root")
@ -141,10 +176,10 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.3769674, 0)
script = SubResource("GDScript_nmc1l")
[node name="SpringArm3D" type="SpringArm3D" parent="CameraPivot" index="0" unique_id=1656112632]
transform = Transform3D(0.9698174, 0, 0.24383235, 0, 1, 0, -0.24383235, 0, 0.9698174, 0.06544638, 0.66225195, 0)
transform = Transform3D(0.9981222, 0, 0.061254278, 0, 1, 0, -0.061254278, 0, 0.9981222, 0.06544638, 0.66225195, 0)
shape = SubResource("SphereShape3D_nmc1l")
spring_length = 3.0
spring_length = 4.0
[node name="Camera3D" type="Camera3D" parent="CameraPivot/SpringArm3D" index="0" unique_id=552400396]
transform = Transform3D(0.9664448, 0.056318317, -0.25062487, 0, 0.97567, 0.2192444, 0.25687462, -0.21188758, 0.9429312, 0, 0, 0)
transform = Transform3D(0.9979606, -5.2219344e-12, -0.0638317, 5.2317426e-12, 1, -1.2884713e-14, 0.0638317, -3.204676e-13, 0.9979606, 0, 0, 0)
fov = 52.5

View file

@ -30,26 +30,36 @@ EnemyHitbox=""
move_left={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
}
move_right={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
move_forward={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
move_back={
"deadzone": 0.2,
"events": [null, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
jab={
"deadzone": 0.2,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(108.19922, 27.601563),"global_position":Vector2(117.19922, 75.60156),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":true,"script":null)
]
}
sweep={
"deadzone": 0.2,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(229.80078, 12.199219),"global_position":Vector2(238.80078, 60.19922),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
]
}

View file

@ -25,16 +25,17 @@ transform = Transform3D(0.2302671, 0.8427532, -0.48656374, 4.2118103e-08, 0.5, 0
shadow_enabled = true
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=1773598072]
use_collision = true
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D" unique_id=624831705]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.121719554, 0)
size = Vector3(10.588867, 0.25, 12.052734)
size = Vector3(37.69922, 0.25, 28.20874)
[node name="bot" parent="." unique_id=1120032835 instance=ExtResource("1_upt1h")]
[node name="bot" parent="." unique_id=1211779765 instance=ExtResource("1_upt1h")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.035994053, 0, -0.025122881)
[node name="bot2" parent="." unique_id=1748234506 instance=ExtResource("2_w0s2s")]
[node name="bot2" parent="." unique_id=708804984 instance=ExtResource("2_w0s2s")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0, -3)
[node name="bot3" parent="." unique_id=2120168079 instance=ExtResource("2_w0s2s")]
[node name="bot3" parent="." unique_id=475346296 instance=ExtResource("2_w0s2s")]
transform = Transform3D(0.3496833, 0, -0.93686795, 0, 1, 0, 0.93686795, 0, 0.3496833, -5.7783833, 0, 3.5097082)