3D Explosions

This commit is contained in:
Marco 2025-06-20 11:28:18 +02:00
commit ad63d2ff43
20 changed files with 207 additions and 19 deletions

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://br01ww57uaky5"]
[gd_scene load_steps=5 format=3 uid="uid://br01ww57uaky5"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_hsg1w"]
[ext_resource type="PackedScene" uid="uid://hxn4awevjyui" path="res://3D/BlockbenchModels/Box/Box_Blue.gltf" id="1_ropdl"]
[ext_resource type="Resource" uid="uid://bes254wblt1lm" path="res://Resources/Bullets/Explosion_Harmless_Small_3D.tres" id="2_cn5xh"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(0.763428, 0.469452, 0.77832)
@ -10,6 +11,7 @@ size = Vector3(0.763428, 0.469452, 0.77832)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_hsg1w")
ExplosionData = ExtResource("2_cn5xh")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00549316, 0.0253752, -0.000488281)

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://c8wwioforxms3"]
[gd_scene load_steps=5 format=3 uid="uid://c8wwioforxms3"]
[ext_resource type="PackedScene" uid="uid://c5k6rsawax3gf" path="res://3D/BlockbenchModels/Box/Box_Green.gltf" id="1_03sp0"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_e6kl3"]
[ext_resource type="Resource" uid="uid://bes254wblt1lm" path="res://Resources/Bullets/Explosion_Harmless_Small_3D.tres" id="2_bguu7"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(0.763428, 0.469452, 0.77832)
@ -10,6 +11,7 @@ size = Vector3(0.763428, 0.469452, 0.77832)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_e6kl3")
ExplosionData = ExtResource("2_bguu7")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00549316, 0.0253752, -0.000488281)

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://jffyxmft3nbw"]
[gd_scene load_steps=5 format=3 uid="uid://jffyxmft3nbw"]
[ext_resource type="PackedScene" uid="uid://ninnis3a3jbn" path="res://3D/BlockbenchModels/Box/Box_Red.gltf" id="1_fi646"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_kvqx7"]
[ext_resource type="Resource" uid="uid://bes254wblt1lm" path="res://Resources/Bullets/Explosion_Harmless_Small_3D.tres" id="2_jolck"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(0.763428, 0.469452, 0.77832)
@ -10,6 +11,7 @@ size = Vector3(0.763428, 0.469452, 0.77832)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_kvqx7")
ExplosionData = ExtResource("2_jolck")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00549316, 0.0253752, -0.000488281)

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://c6cdl3y3i3axl"]
[gd_scene load_steps=5 format=3 uid="uid://c6cdl3y3i3axl"]
[ext_resource type="PackedScene" uid="uid://cpwolnoq46foq" path="res://3D/BlockbenchModels/Box/Box_Yellow.gltf" id="1_0rxnx"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_l0sp5"]
[ext_resource type="Resource" uid="uid://bes254wblt1lm" path="res://Resources/Bullets/Explosion_Harmless_Small_3D.tres" id="2_1if0l"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(0.763428, 0.469452, 0.77832)
@ -10,6 +11,7 @@ size = Vector3(0.763428, 0.469452, 0.77832)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_l0sp5")
ExplosionData = ExtResource("2_1if0l")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00549316, 0.0253752, -0.000488281)

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://b0rhxqjs52fsv"]
[gd_scene load_steps=5 format=3 uid="uid://b0rhxqjs52fsv"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_ix4p0"]
[ext_resource type="Resource" uid="uid://bes254wblt1lm" path="res://Resources/Bullets/Explosion_Harmless_Small_3D.tres" id="2_1t1m8"]
[ext_resource type="PackedScene" uid="uid://bt5weyaiyhtrl" path="res://3D/BlockbenchModels/Camera/Camera.gltf" id="2_ix4p0"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
@ -10,6 +11,7 @@ size = Vector3(0.763428, 0.469452, 0.77832)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_ix4p0")
ExplosionData = ExtResource("2_1t1m8")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00549316, 0.0253752, -0.000488281)

View file

@ -5,7 +5,7 @@
[sub_resource type="CylinderShape3D" id="CylinderShape3D_dkwt8"]
height = 0.882874
[node name="BoxBlue" type="StaticBody3D"]
[node name="CapacitorMini" type="StaticBody3D"]
collision_layer = 16
collision_mask = 0

View file

@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=3 uid="uid://d2kqcbr5rufxb"]
[gd_scene load_steps=5 format=3 uid="uid://d2kqcbr5rufxb"]
[ext_resource type="PackedScene" uid="uid://etmm2bm8mj06" path="res://3D/BlockbenchModels/WoodenBox/Wooden_Box.gltf" id="1_2t24b"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_nnmn3"]
[ext_resource type="Resource" uid="uid://bes254wblt1lm" path="res://Resources/Bullets/Explosion_Harmless_Small_3D.tres" id="2_5j3e2"]
[sub_resource type="BoxShape3D" id="BoxShape3D_hsg1w"]
size = Vector3(1, 0.498138, 0.543457)
@ -10,6 +11,7 @@ size = Vector3(1, 0.498138, 0.543457)
collision_layer = 16
collision_mask = 0
script = ExtResource("1_nnmn3")
ExplosionData = ExtResource("2_5j3e2")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0022127, -0.0178223)

View file

@ -1,14 +1,18 @@
[gd_scene load_steps=3 format=3 uid="uid://c2enjjxlfb5or"]
[gd_scene load_steps=5 format=3 uid="uid://c2enjjxlfb5or"]
[ext_resource type="Texture2D" uid="uid://du8xcvbnf30o2" path="res://ExternalMaterial/Barrel/Barrels.png" id="1_2libs"]
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_gafco"]
[ext_resource type="Resource" uid="uid://bpreje4f8ok62" path="res://Resources/Bullets/Explosion_3D.tres" id="2_g54tg"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_2libs"]
height = 0.564575
radius = 0.321777
[node name="StaticBody3D" type="StaticBody3D"]
[node name="StaticBody3D" type="StaticBody3D" groups=["Destroyable"]]
collision_layer = 16
collision_mask = 0
script = ExtResource("1_gafco")
ExplosionData = ExtResource("2_g54tg")
[node name="Barrel" type="Sprite3D" parent="."]
transform = Transform3D(0.707107, -0.5, 0.5, 0, 0.707107, 0.707107, -0.707107, -0.5, 0.5, 0, 0, 0)

View file

@ -3,25 +3,26 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://b132fhcjm8g7h"
path="res://.godot/imported/Explosion_Procedural_423832.png-4907728ae9c0009f48c6eaca6e6fb992.ctex"
path.s3tc="res://.godot/imported/Explosion_Procedural_423832.png-4907728ae9c0009f48c6eaca6e6fb992.s3tc.ctex"
metadata={
"vram_texture": false
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://ExternalMaterial/Explosion/Explosion_Procedural_423832.png"
dest_files=["res://.godot/imported/Explosion_Procedural_423832.png-4907728ae9c0009f48c6eaca6e6fb992.ctex"]
dest_files=["res://.godot/imported/Explosion_Procedural_423832.png-4907728ae9c0009f48c6eaca6e6fb992.s3tc.ctex"]
[params]
compress/mode=0
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
@ -31,4 +32,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

View file

@ -483,7 +483,7 @@ hframes = 4
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.84862, 0, -4.8932)
[node name="StartPosition" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 56.5542, 1.57535, -10.2971)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 21.5972, 1.57535, 17.7437)
[node name="CameraTarget" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 21.0389, 2.33215, 3.16925)

View file

@ -0,0 +1,24 @@
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://bpreje4f8ok62"]
[ext_resource type="PackedScene" uid="uid://cmd3j4xc2f287" path="res://Scenes/Weapons/Explosion_Bullet_3D.tscn" id="1_ru0fo"]
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_2eq50"]
[resource]
script = ExtResource("2_2eq50")
BulletScene = ExtResource("1_ru0fo")
BulletSpeed = 0.0
Direction = Vector2(1, 0)
BulletDamage = 8.0
MaxDamage = 1.0
Knockback = 1.0
LifeTime = 0.4
DestroyOnCollision = false
Owner = 0
DamageType = 4
RotateSprite = false
Controllable = false
Freezable = true
Grazeable = false
GrazeValue = 1.0
Attributes = 16
TimeModifiers = []

View file

@ -0,0 +1,24 @@
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://c22xvpyn5nxof"]
[ext_resource type="PackedScene" uid="uid://cmd3j4xc2f287" path="res://Scenes/Weapons/Explosion_Bullet_3D.tscn" id="1_x52yr"]
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_w8pa3"]
[resource]
script = ExtResource("2_w8pa3")
BulletScene = ExtResource("1_x52yr")
BulletSpeed = 0.0
Direction = Vector2(1, 0)
BulletDamage = 0.0
MaxDamage = 0.0
Knockback = 0.0
LifeTime = 1.0
DestroyOnCollision = false
Owner = 0
DamageType = 4
RotateSprite = false
Controllable = false
Freezable = false
Grazeable = false
GrazeValue = 1.0
Attributes = 0
TimeModifiers = []

View file

@ -0,0 +1,24 @@
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://bes254wblt1lm"]
[ext_resource type="PackedScene" uid="uid://bu464cgcdnihv" path="res://Scenes/Weapons/Explosion_Bullet_Small_3D.tscn" id="1_3cxov"]
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_spahw"]
[resource]
script = ExtResource("2_spahw")
BulletScene = ExtResource("1_3cxov")
BulletSpeed = 0.0
Direction = Vector2(1, 0)
BulletDamage = 0.0
MaxDamage = 0.0
Knockback = 0.0
LifeTime = 1.0
DestroyOnCollision = false
Owner = 0
DamageType = 4
RotateSprite = false
Controllable = false
Freezable = false
Grazeable = false
GrazeValue = 1.0
Attributes = 0
TimeModifiers = []

View file

@ -0,0 +1,41 @@
[gd_scene load_steps=6 format=3 uid="uid://cmd3j4xc2f287"]
[ext_resource type="Script" uid="uid://cg6y36s7buapp" path="res://Scripts/Weapons/Bullet3D.cs" id="1_l2l87"]
[ext_resource type="Texture2D" uid="uid://cybpmpb0d8yva" path="res://Sprites/Projectile.png" id="2_rmbhq"]
[ext_resource type="SpriteFrames" uid="uid://lh1q76788ixw" path="res://Resources/Sprites/explosion_proc_1.tres" id="3_rmbhq"]
[ext_resource type="Script" uid="uid://cvk4jbit45sfi" path="res://Scripts/Components/Actors/PooledAnimatedSpritePlayer3D.cs" id="4_ny3mn"]
[sub_resource type="SphereShape3D" id="SphereShape3D_pklkt"]
radius = 2.00402
[node name="Explosion" type="Area3D" groups=["bullets"]]
collision_layer = 136
collision_mask = 87
script = ExtResource("1_l2l87")
Speed = 200.0
metadata/_edit_group_ = true
[node name="Sprite" type="Sprite3D" parent="."]
visible = false
pixel_size = 0.05
billboard = 1
texture_filter = 0
texture = ExtResource("2_rmbhq")
[node name="CollisionShape" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_pklkt")
[node name="VisibleOnScreenNotifier" type="VisibleOnScreenNotifier3D" parent="."]
[node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="."]
pixel_size = 0.05
billboard = 1
texture_filter = 0
sprite_frames = ExtResource("3_rmbhq")
autoplay = "default"
script = ExtResource("4_ny3mn")
[connection signal="Initialized" from="." to="AnimatedSprite3D" method="PlayAnimation"]
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
[connection signal="screen_exited" from="VisibleOnScreenNotifier" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]

View file

@ -0,0 +1,41 @@
[gd_scene load_steps=6 format=3 uid="uid://bu464cgcdnihv"]
[ext_resource type="Script" uid="uid://cg6y36s7buapp" path="res://Scripts/Weapons/Bullet3D.cs" id="1_uud1m"]
[ext_resource type="Texture2D" uid="uid://cybpmpb0d8yva" path="res://Sprites/Projectile.png" id="2_alu0c"]
[ext_resource type="SpriteFrames" uid="uid://lh1q76788ixw" path="res://Resources/Sprites/explosion_proc_1.tres" id="3_qsphx"]
[ext_resource type="Script" uid="uid://cvk4jbit45sfi" path="res://Scripts/Components/Actors/PooledAnimatedSpritePlayer3D.cs" id="4_5oowj"]
[sub_resource type="SphereShape3D" id="SphereShape3D_pklkt"]
radius = 2.00402
[node name="Explosion" type="Area3D" groups=["bullets"]]
collision_layer = 136
collision_mask = 87
script = ExtResource("1_uud1m")
Speed = 200.0
metadata/_edit_group_ = true
[node name="Sprite" type="Sprite3D" parent="."]
visible = false
pixel_size = 0.05
billboard = 1
texture_filter = 0
texture = ExtResource("2_alu0c")
[node name="CollisionShape" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_pklkt")
[node name="VisibleOnScreenNotifier" type="VisibleOnScreenNotifier3D" parent="."]
[node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="."]
pixel_size = 0.025
billboard = 1
texture_filter = 0
sprite_frames = ExtResource("3_qsphx")
autoplay = "default"
script = ExtResource("4_5oowj")
[connection signal="Initialized" from="." to="AnimatedSprite3D" method="PlayAnimation"]
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
[connection signal="screen_exited" from="VisibleOnScreenNotifier" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]

View file

@ -65,12 +65,10 @@ public partial class Destructible3D : StaticBody3D, IDestructible
private void CreateExplosion()
{
if (ExplosionData == null) return;
var explosion = PoolingManager.Instance.SpawnBullet<Bullet3D>(ExplosionData);
explosion.GlobalPosition = this.GlobalPosition;
explosion.Speed = 0;
explosion.Initialize(ExplosionData.MakeBullet(new Vector2(this.GlobalPosition.X, this.GlobalPosition.Y)));

View file

@ -0,0 +1,12 @@
using Godot;
namespace Cirno.Scripts.Components.Actors;
public partial class PooledAnimatedSpritePlayer3D : AnimatedSprite3D
{
public void PlayAnimation()
{
this.SetFrame(0);
this.Play();
}
}

View file

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

View file

@ -34,6 +34,9 @@ public partial class Bullet3D : Area3D, IBullet
[Signal]
public delegate void OnDestroyEventHandler();
[Signal]
public delegate void InitializedEventHandler();
private AudioStreamPlayer3D _grazeSound;
private GpuParticles3D _grazeParticles;
@ -65,6 +68,8 @@ public partial class Bullet3D : Area3D, IBullet
// Ugly hack to make instances unique
_modifiers = _bulletInfo.TimeModifiers.Select(x => x.Wrap()).ToList();
EmitSignalInitialized();
}
/// <summary>

View file

@ -392,6 +392,7 @@ locale/translations=PackedStringArray("res://Dialogue/Translations/dialogic_char
2d_physics/layer_6="shoot-through"
3d_physics/layer_6="Items"
2d_physics/layer_7="solid-actors"
3d_physics/layer_7="Enemies"
2d_physics/layer_8="EnemyBullets"
3d_physics/layer_8="EnemyBullets"
2d_physics/layer_9="Acid"