police car weak point
This commit is contained in:
parent
324e7d437b
commit
8a173b968d
15 changed files with 203 additions and 9 deletions
26
enemies/police_car/weak_point.gd
Normal file
26
enemies/police_car/weak_point.gd
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
extends Area3D
|
||||
|
||||
var parent: PoliceCar
|
||||
|
||||
func _ready() -> void:
|
||||
assert(get_parent() is PoliceCar)
|
||||
parent = get_parent()
|
||||
|
||||
func hit(projectile: PlayerProjectile) -> 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue