make projectiles get destroyed when colliding with player
This commit is contained in:
parent
05f2a657f3
commit
2322d8ff62
@ -39,6 +39,7 @@ node_connections = [&"output", 0, &"StateMachine"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_apl1i"]
|
||||
height = 1.8
|
||||
radius = 0.35
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_qsqht"]
|
||||
height = 0.5
|
||||
|
||||
@ -10,10 +10,10 @@ radius = 0.25
|
||||
radius = 0.25
|
||||
height = 0.5
|
||||
|
||||
[node name="Projectile" type="AnimatableBody3D"]
|
||||
[node name="Projectile" type="Area3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
collision_layer = 32
|
||||
collision_mask = 32
|
||||
collision_mask = 48
|
||||
script = ExtResource("1_kv6x5")
|
||||
_collision_debug_material = ExtResource("2_b024o")
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ var _swoop_effect_timer: float
|
||||
func _ready() -> void:
|
||||
Debugger.add_event("attacked")
|
||||
attacked.connect(func() -> void: Debugger.event_emitted("attacked", []))
|
||||
body_entered.connect(_on_body_entered)
|
||||
area_entered.connect(_on_area_entered)
|
||||
|
||||
position.y = Projectile.HEIGHT
|
||||
_set_collision_size(_attack_radius)
|
||||
@ -159,7 +159,7 @@ func _set_collision_size(radius: float) -> void:
|
||||
_swoop_mesh.height = radius
|
||||
|
||||
|
||||
func _on_body_entered(node: Node3D) -> void:
|
||||
func _on_area_entered(node: Node3D) -> void:
|
||||
if _hit_window_timer <= 0:
|
||||
return
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
class_name PlayerMovement
|
||||
extends RefCounted
|
||||
|
||||
@export var _move_speed: float = 10
|
||||
@export var _move_speed: float = 8
|
||||
@export var _move_acceleration: float = 100
|
||||
@export var _move_deceleration: float = 50
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class_name Projectile
|
||||
extends AnimatableBody3D
|
||||
extends Area3D
|
||||
|
||||
const HEIGHT: float = 1
|
||||
|
||||
@ -19,6 +19,7 @@ func _ready() -> void:
|
||||
_debug_collision_shapes.init(get_children(), self, _collision_debug_material)
|
||||
global_position = _start_position
|
||||
global_position.y = HEIGHT
|
||||
body_entered.connect(_on_body_entered)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
@ -37,3 +38,10 @@ func init(velocity: Vector3, start_position: Vector3, lifetime: float = 10) -> v
|
||||
|
||||
func set_velocity(velocity: Vector3) -> void:
|
||||
_velocity = velocity
|
||||
|
||||
|
||||
func _on_body_entered(node: Node3D) -> void:
|
||||
if node is not Player:
|
||||
return
|
||||
|
||||
queue_free()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user