26 lines
705 B
GDScript
26 lines
705 B
GDScript
extends Area3D
|
|
|
|
var parent: PoliceCar
|
|
|
|
func _ready() -> void:
|
|
assert(get_parent() is PoliceCar)
|
|
parent = get_parent()
|
|
|
|
func hit(projectile: PlayerProjectile, _damage: float) -> bool:
|
|
if projectile == null: return false
|
|
|
|
var angle := projectile.velocity.angle_to(-parent.velocity)
|
|
var weak_point_hit := rad_to_deg(angle) < 25.
|
|
|
|
if weak_point_hit:
|
|
var explosion := preload("res://player/explosion/explosion.tscn").instantiate()
|
|
explosion.position = parent.position
|
|
parent.add_sibling(explosion)
|
|
|
|
var label_vfx := preload("res://utils/label_vfx/label_vfx.tscn").instantiate()
|
|
label_vfx.position = parent.position
|
|
parent.add_sibling(label_vfx)
|
|
|
|
parent.queue_free()
|
|
|
|
return weak_point_hit
|