add hitting projectile function
This commit is contained in:
parent
cd7bc7a82f
commit
80b7881cc6
@ -21,9 +21,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
|||||||
mesh = SubResource("BoxMesh_860q6")
|
mesh = SubResource("BoxMesh_860q6")
|
||||||
|
|
||||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="MeshInstance3D"]
|
[node name="MeshInstance3D2" type="MeshInstance3D" parent="MeshInstance3D"]
|
||||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -0.339801)
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.552548, -0.339801)
|
||||||
mesh = SubResource("CylinderMesh_esok8")
|
mesh = SubResource("CylinderMesh_esok8")
|
||||||
skeleton = NodePath("../..")
|
skeleton = NodePath("../..")
|
||||||
|
|
||||||
[node name="Marker3D" type="Marker3D" parent="."]
|
[node name="Marker3D" type="Marker3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.624811, -0.590804)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.036, -0.590804)
|
||||||
|
|||||||
@ -14,9 +14,9 @@ height = 1.8
|
|||||||
[sub_resource type="BoxMesh" id="BoxMesh_fdktb"]
|
[sub_resource type="BoxMesh" id="BoxMesh_fdktb"]
|
||||||
size = Vector3(0.5, 0.5, 0.5)
|
size = Vector3(0.5, 0.5, 0.5)
|
||||||
|
|
||||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_m8fdo"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_5qjrf"]
|
||||||
height = 1.0
|
radius = 2.0
|
||||||
radius = 1.5
|
height = 6.0
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D"]
|
[node name="Player" type="CharacterBody3D"]
|
||||||
collision_layer = 16
|
collision_layer = 16
|
||||||
@ -36,11 +36,11 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.17779, 0.357218)
|
|||||||
mesh = SubResource("BoxMesh_fdktb")
|
mesh = SubResource("BoxMesh_fdktb")
|
||||||
|
|
||||||
[node name="AttackArea" type="Area3D" parent="."]
|
[node name="AttackArea" type="Area3D" parent="."]
|
||||||
collision_layer = 0
|
collision_layer = 32
|
||||||
collision_mask = 32
|
collision_mask = 32
|
||||||
script = ExtResource("3_8pbtx")
|
script = ExtResource("3_8pbtx")
|
||||||
_collision_debug_material = ExtResource("4_ll2ct")
|
_collision_debug_material = ExtResource("4_ll2ct")
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="AttackArea"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="AttackArea"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||||
shape = SubResource("CylinderShape3D_m8fdo")
|
shape = SubResource("CapsuleShape3D_5qjrf")
|
||||||
|
|||||||
@ -10,8 +10,8 @@ radius = 0.25
|
|||||||
radius = 0.25
|
radius = 0.25
|
||||||
height = 0.5
|
height = 0.5
|
||||||
|
|
||||||
[node name="Projectile" type="Area3D"]
|
[node name="Projectile" type="AnimatableBody3D"]
|
||||||
top_level = true
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.535, 0)
|
||||||
collision_layer = 32
|
collision_layer = 32
|
||||||
collision_mask = 32
|
collision_mask = 32
|
||||||
script = ExtResource("1_kv6x5")
|
script = ExtResource("1_kv6x5")
|
||||||
|
|||||||
@ -12,6 +12,7 @@ func _ready() -> void:
|
|||||||
_debug_collision_shapes.init(get_children(), self, _collision_debug_material)
|
_debug_collision_shapes.init(get_children(), self, _collision_debug_material)
|
||||||
Debugger.add_event("attacked")
|
Debugger.add_event("attacked")
|
||||||
attacked.connect(func() -> void: Debugger.event_emitted("attacked", []))
|
attacked.connect(func() -> void: Debugger.event_emitted("attacked", []))
|
||||||
|
body_entered.connect(_on_body_entered)
|
||||||
|
|
||||||
|
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
@ -21,3 +22,12 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
|
|
||||||
func _attack() -> void:
|
func _attack() -> void:
|
||||||
attacked.emit()
|
attacked.emit()
|
||||||
|
|
||||||
|
|
||||||
|
func _hit_projectile(projectile: Projectile) -> void:
|
||||||
|
projectile.queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_body_entered(node: Node3D) -> void:
|
||||||
|
if node is Projectile:
|
||||||
|
_hit_projectile(node as Projectile)
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
class_name Projectile
|
class_name Projectile
|
||||||
extends Area3D
|
extends AnimatableBody3D
|
||||||
|
|
||||||
@export var _collision_debug_material: Material
|
@export var _collision_debug_material: Material
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ func _ready() -> void:
|
|||||||
global_position = _start_position
|
global_position = _start_position
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
if _life_timer <= 0:
|
if _life_timer <= 0:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
@ -30,3 +30,7 @@ func init(velocity: Vector3, start_position: Vector3, lifetime: float = 10) -> v
|
|||||||
_velocity = velocity
|
_velocity = velocity
|
||||||
_start_position = start_position
|
_start_position = start_position
|
||||||
_lifetime = lifetime
|
_lifetime = lifetime
|
||||||
|
|
||||||
|
|
||||||
|
func set_velocity(velocity: Vector3) -> void:
|
||||||
|
_velocity = velocity
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user