mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-15 00:14:48 +00:00
✨ Health and AreaDamage components, death and respawn logic
This commit is contained in:
parent
3d21d9a5aa
commit
ce1cdda7a1
13 changed files with 121 additions and 22 deletions
|
|
@ -1,7 +1,7 @@
|
|||
extends Node3D
|
||||
|
||||
@onready var fire = $Fire
|
||||
@onready var explosion_area = $Area3D
|
||||
@onready var explosion_area : AreaDamageComponent = $AreaDamageComponent
|
||||
var explosion_effect_pending : bool = false
|
||||
|
||||
const impulse_force = 1000;
|
||||
|
|
@ -9,16 +9,16 @@ const impulse_force = 1000;
|
|||
func explode():
|
||||
explosion_effect_pending = true
|
||||
fire.emitting = true
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
if explosion_effect_pending:
|
||||
var bodies = explosion_area.get_overlapping_bodies()
|
||||
|
||||
|
||||
for body in bodies:
|
||||
if body is RigidBody3D:
|
||||
var direction = (body.global_position - global_position).normalized()
|
||||
body.apply_central_impulse(direction * impulse_force)
|
||||
|
||||
|
||||
explosion_effect_pending = false
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
queue_free()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://8atq41j7wd55"]
|
||||
|
||||
[ext_resource type="Script" path="res://weapons/space_gun/projectile_explosion.gd" id="1_fp5td"]
|
||||
[ext_resource type="PackedScene" uid="uid://ds1hekx1dq1bg" path="res://components/area_damage_component.tscn" id="2_reyvo"]
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_3mf41"]
|
||||
spread = 180.0
|
||||
|
|
@ -16,9 +17,6 @@ emission_energy_multiplier = 4.0
|
|||
[sub_resource type="SphereMesh" id="SphereMesh_k3pnh"]
|
||||
material = SubResource("StandardMaterial3D_wpu51")
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_ou8x6"]
|
||||
radius = 5.0
|
||||
|
||||
[node name="ProjectileExplosion" type="Node3D"]
|
||||
script = ExtResource("1_fp5td")
|
||||
|
||||
|
|
@ -32,8 +30,4 @@ fixed_fps = 60
|
|||
process_material = SubResource("ParticleProcessMaterial_3mf41")
|
||||
draw_pass_1 = SubResource("SphereMesh_k3pnh")
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="."]
|
||||
input_ray_pickable = false
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
|
||||
shape = SubResource("SphereShape3D_ou8x6")
|
||||
[node name="AreaDamageComponent" parent="." instance=ExtResource("2_reyvo")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue