add character contorller and damage handling
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
extends RefCounted
|
||||
enum TargetType{
|
||||
PLAYER = 1 << 0, # 1 0001
|
||||
ENEMY = 1 << 1, # 2 0010
|
||||
OBJECT = 1 << 2, # 4 0100
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bmlsp6evve20
|
||||
@@ -0,0 +1,19 @@
|
||||
class_name HitBox extends Area2D
|
||||
|
||||
@export var damage:float = 10
|
||||
@export_flags("player","enemy") var affect:int = 0
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
print(affect)
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
||||
|
||||
func hit():
|
||||
for i in get_overlapping_areas():
|
||||
if i is HurtBox:
|
||||
i.on_damage_receieved(self)
|
||||
@@ -0,0 +1 @@
|
||||
uid://ctbguk3d6wxli
|
||||
@@ -0,0 +1,18 @@
|
||||
class_name HurtBox extends Area2D
|
||||
|
||||
signal damage_recieved(damage:float)
|
||||
@export_flags("player","enemy") var type
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func on_damage_receieved(hitbox:HitBox):
|
||||
if hitbox.affect & type:
|
||||
damage_recieved.emit(hitbox.damage)
|
||||
#if type
|
||||
@@ -0,0 +1 @@
|
||||
uid://dg8f4mexv447m
|
||||
Reference in New Issue
Block a user