add player attack node
This commit is contained in:
@@ -10,6 +10,8 @@ var aiming: PlayerAiming = PlayerAiming.new()
|
||||
var _respawn_point: Vector3
|
||||
var _debug_collision_shapes := DebugCollisionShapes.new()
|
||||
|
||||
@onready var attack: PlayerAttack = $AttackArea
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_respawn_point = global_position
|
||||
|
||||
23
scripts/player/player_attack.gd
Normal file
23
scripts/player/player_attack.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
class_name PlayerAttack
|
||||
extends Area3D
|
||||
|
||||
signal attacked
|
||||
|
||||
@export var _collision_debug_material: Material
|
||||
|
||||
var _debug_collision_shapes := DebugCollisionShapes.new()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_debug_collision_shapes.init(get_children(), self, _collision_debug_material)
|
||||
Debugger.add_event("attacked")
|
||||
attacked.connect(func() -> void: Debugger.event_emitted("attacked", []))
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("attack"):
|
||||
_attack()
|
||||
|
||||
|
||||
func _attack() -> void:
|
||||
attacked.emit()
|
||||
Reference in New Issue
Block a user