make projectiles get destroyed when colliding with player
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user