police car weak point

This commit is contained in:
Michael Campbell 2026-02-18 16:46:00 -05:00
parent 324e7d437b
commit 8a173b968d
15 changed files with 203 additions and 9 deletions

View file

@ -15,8 +15,9 @@ func _physics_process(delta: float) -> void:
rotation.y = Vector2(velocity.x, -velocity.z).angle()
func hit(_proj: PlayerProjectile):
func hit(_proj: PlayerProjectile) -> bool:
queue_free()
return true
func _on_hurtbox_body_entered(body: Node3D) -> void:

View file

@ -1,6 +1,7 @@
[gd_scene format=3 uid="uid://dusfu1hidkmsk"]
[ext_resource type="Script" uid="uid://c6xr2j0g1ep7j" path="res://enemies/police_car/police_car.gd" id="1_spw8y"]
[ext_resource type="Script" uid="uid://c14x24qxx1wc3" path="res://enemies/police_car/weak_point.gd" id="2_8ru0n"]
[sub_resource type="Curve" id="Curve_spw8y"]
_limits = [1.0, 20.0, -1.0, 1.0]
@ -30,6 +31,9 @@ height = 0.5
[sub_resource type="BoxShape3D" id="BoxShape3D_8364l"]
size = Vector3(1.7734375, 0.5839844, 1.1367188)
[sub_resource type="BoxShape3D" id="BoxShape3D_s5uvd"]
size = Vector3(0.6993408, 1, 0.88671875)
[node name="PoliceCar" type="CharacterBody3D" unique_id=206023291]
collision_layer = 8
collision_mask = 15
@ -74,4 +78,13 @@ transform = Transform3D(2, 0, 0, 0, 2, 0, 0, 0, 2, -0.122092836, 0.34972915, -0.
shape = SubResource("BoxShape3D_8364l")
debug_color = Color(0.9913104, 0, 0.27320355, 0.41960785)
[node name="WeakPoint" type="Area3D" parent="." unique_id=1032610086]
collision_layer = 8
collision_mask = 0
script = ExtResource("2_8ru0n")
[node name="CollisionShape3D" type="CollisionShape3D" parent="WeakPoint" unique_id=950314743]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.9923661, 0.27572453, -0.0006608963)
shape = SubResource("BoxShape3D_s5uvd")
[connection signal="body_entered" from="Hurtbox" to="." method="_on_hurtbox_body_entered"]

View 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

View file

@ -0,0 +1 @@
uid://c14x24qxx1wc3