Demo: Refactor arena and add dummy
This commit is contained in:
parent
2451cf801f
commit
102a770c42
|
@ -23,7 +23,7 @@ func _ready() -> void:
|
|||
func _area_entered(hurtbox: Hurtbox) -> void:
|
||||
if hurtbox.owner == owner:
|
||||
return
|
||||
hurtbox.take_damage(damage, get_knockback())
|
||||
hurtbox.take_damage(damage, get_knockback(), self)
|
||||
|
||||
|
||||
func get_knockback() -> Vector2:
|
||||
|
|
|
@ -15,6 +15,9 @@ extends Area2D
|
|||
|
||||
@export var health: Health
|
||||
|
||||
var last_attack_vector: Vector2
|
||||
|
||||
func take_damage(amount: float, knockback: Vector2) -> void:
|
||||
|
||||
func take_damage(amount: float, knockback: Vector2, source: Hitbox) -> void:
|
||||
last_attack_vector = owner.global_position - source.owner.global_position
|
||||
health.take_damage(amount, knockback)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@onready var hurtbox: Hurtbox = $Hurtbox
|
||||
@onready var root: Node2D = $Root
|
||||
|
||||
func _on_health_damaged(_amount: float, _knockback: Vector2) -> void:
|
||||
root.scale.x = -signf(hurtbox.last_attack_vector.x)
|
||||
animation_player.clear_queue()
|
||||
animation_player.play(&"hurt", 0.1)
|
||||
|
|
@ -1,14 +1,17 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://c5fhe3tulhlco"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://c5fhe3tulhlco"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/props/dummy.gd" id="1_kqftw"]
|
||||
[ext_resource type="Texture2D" uid="uid://cltutcxjx8jnl" path="res://demo/assets/dummy.png" id="1_vdhcl"]
|
||||
[ext_resource type="Texture2D" uid="uid://dwhhxj5557qrb" path="res://demo/assets/shadow.png" id="2_535g7"]
|
||||
[ext_resource type="Script" path="res://demo/agents/scripts/hurtbox.gd" id="4_pkfnd"]
|
||||
[ext_resource type="Script" path="res://demo/agents/scripts/health.gd" id="5_8qcls"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_1o3gy"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Rig:position")
|
||||
tracks/0/path = NodePath("Root/Rig:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
|
@ -20,7 +23,7 @@ tracks/0/keys = {
|
|||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Rig:rotation")
|
||||
tracks/1/path = NodePath("Root/Rig:rotation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
|
@ -32,7 +35,7 @@ tracks/1/keys = {
|
|||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Rig:scale")
|
||||
tracks/2/path = NodePath("Root/Rig:scale")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
|
@ -44,7 +47,7 @@ tracks/2/keys = {
|
|||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("Rig/Stick:position")
|
||||
tracks/3/path = NodePath("Root/Rig/Stick:position")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
|
@ -56,7 +59,7 @@ tracks/3/keys = {
|
|||
tracks/4/type = "value"
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/path = NodePath("Rig/Stick:rotation")
|
||||
tracks/4/path = NodePath("Root/Rig/Stick:rotation")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/keys = {
|
||||
|
@ -68,7 +71,7 @@ tracks/4/keys = {
|
|||
tracks/5/type = "value"
|
||||
tracks/5/imported = false
|
||||
tracks/5/enabled = true
|
||||
tracks/5/path = NodePath("Rig/Stick:scale")
|
||||
tracks/5/path = NodePath("Root/Rig/Stick:scale")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/loop_wrap = true
|
||||
tracks/5/keys = {
|
||||
|
@ -80,7 +83,7 @@ tracks/5/keys = {
|
|||
tracks/6/type = "value"
|
||||
tracks/6/imported = false
|
||||
tracks/6/enabled = true
|
||||
tracks/6/path = NodePath("Rig/Stick/Body:position")
|
||||
tracks/6/path = NodePath("Root/Rig/Stick/Body:position")
|
||||
tracks/6/interp = 1
|
||||
tracks/6/loop_wrap = true
|
||||
tracks/6/keys = {
|
||||
|
@ -92,7 +95,7 @@ tracks/6/keys = {
|
|||
tracks/7/type = "value"
|
||||
tracks/7/imported = false
|
||||
tracks/7/enabled = true
|
||||
tracks/7/path = NodePath("Rig/Stick/Body:rotation")
|
||||
tracks/7/path = NodePath("Root/Rig/Stick/Body:rotation")
|
||||
tracks/7/interp = 1
|
||||
tracks/7/loop_wrap = true
|
||||
tracks/7/keys = {
|
||||
|
@ -104,7 +107,7 @@ tracks/7/keys = {
|
|||
tracks/8/type = "value"
|
||||
tracks/8/imported = false
|
||||
tracks/8/enabled = true
|
||||
tracks/8/path = NodePath("Rig/Stick/Body:scale")
|
||||
tracks/8/path = NodePath("Root/Rig/Stick/Body:scale")
|
||||
tracks/8/interp = 1
|
||||
tracks/8/loop_wrap = true
|
||||
tracks/8/keys = {
|
||||
|
@ -121,7 +124,7 @@ step = 0.05
|
|||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Rig:position")
|
||||
tracks/0/path = NodePath("Root/Rig:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
|
@ -133,7 +136,7 @@ tracks/0/keys = {
|
|||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Rig:rotation")
|
||||
tracks/1/path = NodePath("Root/Rig:rotation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
|
@ -145,7 +148,7 @@ tracks/1/keys = {
|
|||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Rig:scale")
|
||||
tracks/2/path = NodePath("Root/Rig:scale")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
|
@ -157,7 +160,7 @@ tracks/2/keys = {
|
|||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("Rig/Stick:position")
|
||||
tracks/3/path = NodePath("Root/Rig/Stick:position")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
|
@ -169,7 +172,7 @@ tracks/3/keys = {
|
|||
tracks/4/type = "value"
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/path = NodePath("Rig/Stick:rotation")
|
||||
tracks/4/path = NodePath("Root/Rig/Stick:rotation")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/keys = {
|
||||
|
@ -181,7 +184,7 @@ tracks/4/keys = {
|
|||
tracks/5/type = "value"
|
||||
tracks/5/imported = false
|
||||
tracks/5/enabled = true
|
||||
tracks/5/path = NodePath("Rig/Stick:scale")
|
||||
tracks/5/path = NodePath("Root/Rig/Stick:scale")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/loop_wrap = true
|
||||
tracks/5/keys = {
|
||||
|
@ -193,7 +196,7 @@ tracks/5/keys = {
|
|||
tracks/6/type = "value"
|
||||
tracks/6/imported = false
|
||||
tracks/6/enabled = true
|
||||
tracks/6/path = NodePath("Rig/Stick/Body:position")
|
||||
tracks/6/path = NodePath("Root/Rig/Stick/Body:position")
|
||||
tracks/6/interp = 1
|
||||
tracks/6/loop_wrap = true
|
||||
tracks/6/keys = {
|
||||
|
@ -205,7 +208,7 @@ tracks/6/keys = {
|
|||
tracks/7/type = "value"
|
||||
tracks/7/imported = false
|
||||
tracks/7/enabled = true
|
||||
tracks/7/path = NodePath("Rig/Stick/Body:rotation")
|
||||
tracks/7/path = NodePath("Root/Rig/Stick/Body:rotation")
|
||||
tracks/7/interp = 1
|
||||
tracks/7/loop_wrap = true
|
||||
tracks/7/keys = {
|
||||
|
@ -217,7 +220,7 @@ tracks/7/keys = {
|
|||
tracks/8/type = "value"
|
||||
tracks/8/imported = false
|
||||
tracks/8/enabled = true
|
||||
tracks/8/path = NodePath("Rig/Stick/Body:scale")
|
||||
tracks/8/path = NodePath("Root/Rig/Stick/Body:scale")
|
||||
tracks/8/interp = 1
|
||||
tracks/8/loop_wrap = true
|
||||
tracks/8/keys = {
|
||||
|
@ -234,7 +237,7 @@ loop_mode = 1
|
|||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Rig:position")
|
||||
tracks/0/path = NodePath("Root/Rig:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
|
@ -246,7 +249,7 @@ tracks/0/keys = {
|
|||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Rig:rotation")
|
||||
tracks/1/path = NodePath("Root/Rig:rotation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
|
@ -258,7 +261,7 @@ tracks/1/keys = {
|
|||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("Rig:scale")
|
||||
tracks/2/path = NodePath("Root/Rig:scale")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
|
@ -270,7 +273,7 @@ tracks/2/keys = {
|
|||
tracks/3/type = "value"
|
||||
tracks/3/imported = false
|
||||
tracks/3/enabled = true
|
||||
tracks/3/path = NodePath("Rig/Stick:position")
|
||||
tracks/3/path = NodePath("Root/Rig/Stick:position")
|
||||
tracks/3/interp = 1
|
||||
tracks/3/loop_wrap = true
|
||||
tracks/3/keys = {
|
||||
|
@ -282,7 +285,7 @@ tracks/3/keys = {
|
|||
tracks/4/type = "value"
|
||||
tracks/4/imported = false
|
||||
tracks/4/enabled = true
|
||||
tracks/4/path = NodePath("Rig/Stick:rotation")
|
||||
tracks/4/path = NodePath("Root/Rig/Stick:rotation")
|
||||
tracks/4/interp = 1
|
||||
tracks/4/loop_wrap = true
|
||||
tracks/4/keys = {
|
||||
|
@ -294,7 +297,7 @@ tracks/4/keys = {
|
|||
tracks/5/type = "value"
|
||||
tracks/5/imported = false
|
||||
tracks/5/enabled = true
|
||||
tracks/5/path = NodePath("Rig/Stick:scale")
|
||||
tracks/5/path = NodePath("Root/Rig/Stick:scale")
|
||||
tracks/5/interp = 1
|
||||
tracks/5/loop_wrap = true
|
||||
tracks/5/keys = {
|
||||
|
@ -306,7 +309,7 @@ tracks/5/keys = {
|
|||
tracks/6/type = "value"
|
||||
tracks/6/imported = false
|
||||
tracks/6/enabled = true
|
||||
tracks/6/path = NodePath("Rig/Stick/Body:position")
|
||||
tracks/6/path = NodePath("Root/Rig/Stick/Body:position")
|
||||
tracks/6/interp = 1
|
||||
tracks/6/loop_wrap = true
|
||||
tracks/6/keys = {
|
||||
|
@ -318,7 +321,7 @@ tracks/6/keys = {
|
|||
tracks/7/type = "value"
|
||||
tracks/7/imported = false
|
||||
tracks/7/enabled = true
|
||||
tracks/7/path = NodePath("Rig/Stick/Body:rotation")
|
||||
tracks/7/path = NodePath("Root/Rig/Stick/Body:rotation")
|
||||
tracks/7/interp = 1
|
||||
tracks/7/loop_wrap = true
|
||||
tracks/7/keys = {
|
||||
|
@ -330,7 +333,7 @@ tracks/7/keys = {
|
|||
tracks/8/type = "value"
|
||||
tracks/8/imported = false
|
||||
tracks/8/enabled = true
|
||||
tracks/8/path = NodePath("Rig/Stick/Body:scale")
|
||||
tracks/8/path = NodePath("Root/Rig/Stick/Body:scale")
|
||||
tracks/8/interp = 1
|
||||
tracks/8/loop_wrap = true
|
||||
tracks/8/keys = {
|
||||
|
@ -347,22 +350,29 @@ _data = {
|
|||
"idle": SubResource("Animation_sf5ej")
|
||||
}
|
||||
|
||||
[node name="Dummy" type="Node2D"]
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pknym"]
|
||||
size = Vector2(80, 35)
|
||||
|
||||
[node name="Rig" type="Node2D" parent="."]
|
||||
[node name="Dummy" type="CharacterBody2D" groups=["player"]]
|
||||
script = ExtResource("1_kqftw")
|
||||
|
||||
[node name="Shadow" type="Sprite2D" parent="Rig"]
|
||||
[node name="Root" type="Node2D" parent="."]
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="Rig" type="Node2D" parent="Root"]
|
||||
|
||||
[node name="Shadow" type="Sprite2D" parent="Root/Rig"]
|
||||
modulate = Color(1, 1, 1, 0.290196)
|
||||
texture = ExtResource("2_535g7")
|
||||
|
||||
[node name="Stick" type="Sprite2D" parent="Rig"]
|
||||
[node name="Stick" type="Sprite2D" parent="Root/Rig"]
|
||||
position = Vector2(0, -1)
|
||||
texture = ExtResource("1_vdhcl")
|
||||
offset = Vector2(-1, -28)
|
||||
region_enabled = true
|
||||
region_rect = Rect2(100.613, 0, 22.3875, 64.0292)
|
||||
|
||||
[node name="Body" type="Sprite2D" parent="Rig/Stick"]
|
||||
[node name="Body" type="Sprite2D" parent="Root/Rig/Stick"]
|
||||
position = Vector2(0, -49)
|
||||
texture = ExtResource("1_vdhcl")
|
||||
offset = Vector2(-1, -56)
|
||||
|
@ -374,3 +384,22 @@ libraries = {
|
|||
"": SubResource("AnimationLibrary_blnjx")
|
||||
}
|
||||
autoplay = "idle"
|
||||
next/hurt = &"idle"
|
||||
blend_times = [&"idle", &"hurt", 0.05, &"hurt", &"idle", 0.3]
|
||||
|
||||
[node name="Hurtbox" type="Area2D" parent="." node_paths=PackedStringArray("health")]
|
||||
collision_layer = 4
|
||||
collision_mask = 0
|
||||
script = ExtResource("4_pkfnd")
|
||||
health = NodePath("../Health")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox"]
|
||||
shape = SubResource("RectangleShape2D_pknym")
|
||||
debug_color = Color(0.466325, 0.590206, 0.107862, 0.42)
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="Health" type="Node" parent="."]
|
||||
script = ExtResource("5_8qcls")
|
||||
max_health = 1e+07
|
||||
|
||||
[connection signal="damaged" from="Health" to="." method="_on_health_damaged"]
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://b3ae14mc2ty3y"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/arena.tscn" id="1_cyyay"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5fhe3tulhlco" path="res://demo/props/dummy.tscn" id="2_gp6iv"]
|
||||
[ext_resource type="PackedScene" uid="uid://730bthc0ywhd" path="res://demo/agents/agent_imp.tscn" id="3_p2jr5"]
|
||||
|
||||
[node name="01 - Imp Demo" type="Node2D"]
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="Arena" parent="." instance=ExtResource("1_cyyay")]
|
||||
|
||||
[node name="Dummy" parent="." instance=ExtResource("2_gp6iv")]
|
||||
position = Vector2(1106, 423)
|
||||
|
||||
[node name="AgentImp" parent="." instance=ExtResource("3_p2jr5")]
|
||||
position = Vector2(1623, 426)
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="AgentImp"]
|
||||
zoom = Vector2(0.88, 0.88)
|
||||
process_callback = 0
|
||||
position_smoothing_enabled = true
|
||||
drag_horizontal_enabled = true
|
||||
drag_vertical_enabled = true
|
||||
drag_top_margin = 0.1
|
||||
drag_bottom_margin = 0.1
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -11,7 +11,7 @@ config_version=5
|
|||
[application]
|
||||
|
||||
config/name="LimboAI Demo"
|
||||
run/main_scene="res://demo/scenes/demo.tscn"
|
||||
run/main_scene="res://demo/scenes/arena.tscn"
|
||||
config/features=PackedStringArray("4.2", "Forward Plus")
|
||||
config/icon="res://demo/icon.svg"
|
||||
|
||||
|
|
Loading…
Reference in New Issue