add player attack node
This commit is contained in:
parent
8b53eaa6ed
commit
d53fe046a8
@ -113,6 +113,12 @@ aim_right={
|
||||
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
|
||||
]
|
||||
}
|
||||
attack={
|
||||
"deadzone": 0.5,
|
||||
"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(118, 11),"global_position":Vector2(127, 57),"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":10,"pressure":0.0,"pressed":true,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
||||
15
resources/materials/debug/debug_attack.tres
Normal file
15
resources/materials/debug/debug_attack.tres
Normal file
@ -0,0 +1,15 @@
|
||||
[gd_resource type="StandardMaterial3D" load_steps=3 format=3 uid="uid://bdi02rpvdukem"]
|
||||
|
||||
[ext_resource type="Shader" path="res://shaders/wireframe.gdshader" id="1_ooap1"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ionb4"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_ooap1")
|
||||
shader_parameter/albedo = Color(0.778762, 0.602207, 1.92523e-07, 0.435294)
|
||||
shader_parameter/outline_width = 0.0
|
||||
|
||||
[resource]
|
||||
next_pass = SubResource("ShaderMaterial_ionb4")
|
||||
transparency = 1
|
||||
shading_mode = 0
|
||||
albedo_color = Color(0.778762, 0.602207, 1.92523e-07, 0.435294)
|
||||
@ -1,7 +1,9 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://b73y71y3efmv"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://b73y71y3efmv"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/player/player.gd" id="1_xt3i8"]
|
||||
[ext_resource type="Material" uid="uid://cc18ee0wbfoud" path="res://resources/materials/debug/debug_player.tres" id="2_0p422"]
|
||||
[ext_resource type="Script" path="res://scripts/player/player_attack.gd" id="3_8pbtx"]
|
||||
[ext_resource type="Material" uid="uid://bdi02rpvdukem" path="res://resources/materials/debug/debug_attack.tres" id="4_ll2ct"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_apl1i"]
|
||||
height = 1.8
|
||||
@ -36,6 +38,8 @@ mesh = SubResource("BoxMesh_fdktb")
|
||||
[node name="AttackArea" type="Area3D" parent="."]
|
||||
collision_layer = 0
|
||||
collision_mask = 32
|
||||
script = ExtResource("3_8pbtx")
|
||||
_collision_debug_material = ExtResource("4_ll2ct")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="AttackArea"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
|
||||
@ -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()
|
||||
Loading…
Reference in New Issue
Block a user