feat: integrated some assets and made a hitbox and damage reaction system
This commit is contained in:
13
damageable/damageable.gd
Normal file
13
damageable/damageable.gd
Normal file
@ -0,0 +1,13 @@
|
||||
extends Node
|
||||
class_name Damageable
|
||||
|
||||
|
||||
@export var health = 3
|
||||
@export var hitback_velocity: float = 500
|
||||
|
||||
signal got_hit
|
||||
|
||||
func damage(value: int = 0, direction: Vector2 = Vector2.UP):
|
||||
health -= value
|
||||
get_parent().velocity = hitback_velocity * direction
|
||||
got_hit.emit()
|
1
damageable/damageable.gd.uid
Normal file
1
damageable/damageable.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bhbn4pngdfk7w
|
6
damageable/damageable.tscn
Normal file
6
damageable/damageable.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://djwoetcyvvofc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bhbn4pngdfk7w" path="res://damageable/damageable.gd" id="1_qv54c"]
|
||||
|
||||
[node name="Damageable" type="Node"]
|
||||
script = ExtResource("1_qv54c")
|
9
damageable/hitbox.gd
Normal file
9
damageable/hitbox.gd
Normal file
@ -0,0 +1,9 @@
|
||||
extends Area2D
|
||||
|
||||
@export var damage = 0
|
||||
@export var hitback_direction = Vector2.UP
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
for child in body.get_children():
|
||||
if is_instance_of(child, Damageable):
|
||||
child.damage(damage, hitback_direction)
|
1
damageable/hitbox.gd.uid
Normal file
1
damageable/hitbox.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dt2lsk3je41th
|
8
damageable/hitbox.tscn
Normal file
8
damageable/hitbox.tscn
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://7sqwi3lygb1u"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dt2lsk3je41th" path="res://damageable/hitbox.gd" id="1_n3l2p"]
|
||||
|
||||
[node name="Hitbox" type="Area2D"]
|
||||
script = ExtResource("1_n3l2p")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
Reference in New Issue
Block a user