From ad63d2ff43ec39fc4c5f6eaad71fd02178eb592f Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 20 Jun 2025 11:28:18 +0200 Subject: [PATCH] 3D Explosions --- 3D/Scenes/Props/Box_3D_Blue.tscn | 4 +- 3D/Scenes/Props/Box_3D_Green.tscn | 4 +- 3D/Scenes/Props/Box_3D_Red.tscn | 4 +- 3D/Scenes/Props/Box_3D_Yellow.tscn | 4 +- 3D/Scenes/Props/Camera_3D.tscn | 4 +- 3D/Scenes/Props/Capacitor_Mini_3D.tscn | 2 +- 3D/Scenes/Props/Wooden_Box.tscn | 4 +- 3D/Scenes/Props/barrel_3d.tscn | 8 +++- .../Explosion_Procedural_423832.png.import | 13 +++--- IsoTest/IsoMapTest2.tscn | 2 +- Resources/Bullets/Explosion_3D.tres | 24 +++++++++++ Resources/Bullets/Explosion_Harmless_3D.tres | 24 +++++++++++ .../Bullets/Explosion_Harmless_Small_3D.tres | 24 +++++++++++ Scenes/Weapons/Explosion_Bullet_3D.tscn | 41 +++++++++++++++++++ Scenes/Weapons/Explosion_Bullet_Small_3D.tscn | 41 +++++++++++++++++++ Scripts/Actors/Destructible3D.cs | 4 +- .../Actors/PooledAnimatedSpritePlayer3D.cs | 12 ++++++ .../PooledAnimatedSpritePlayer3D.cs.uid | 1 + Scripts/Weapons/Bullet3D.cs | 5 +++ project.godot | 1 + 20 files changed, 207 insertions(+), 19 deletions(-) create mode 100644 Resources/Bullets/Explosion_3D.tres create mode 100644 Resources/Bullets/Explosion_Harmless_3D.tres create mode 100644 Resources/Bullets/Explosion_Harmless_Small_3D.tres create mode 100644 Scenes/Weapons/Explosion_Bullet_3D.tscn create mode 100644 Scenes/Weapons/Explosion_Bullet_Small_3D.tscn create mode 100644 Scripts/Components/Actors/PooledAnimatedSpritePlayer3D.cs create mode 100644 Scripts/Components/Actors/PooledAnimatedSpritePlayer3D.cs.uid diff --git a/3D/Scenes/Props/Box_3D_Blue.tscn b/3D/Scenes/Props/Box_3D_Blue.tscn index 11afcf4b..408a4262 100644 --- a/3D/Scenes/Props/Box_3D_Blue.tscn +++ b/3D/Scenes/Props/Box_3D_Blue.tscn @@ -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) diff --git a/3D/Scenes/Props/Box_3D_Green.tscn b/3D/Scenes/Props/Box_3D_Green.tscn index 8338bfb0..2221ab86 100644 --- a/3D/Scenes/Props/Box_3D_Green.tscn +++ b/3D/Scenes/Props/Box_3D_Green.tscn @@ -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) diff --git a/3D/Scenes/Props/Box_3D_Red.tscn b/3D/Scenes/Props/Box_3D_Red.tscn index 39c3f6aa..f6f5faff 100644 --- a/3D/Scenes/Props/Box_3D_Red.tscn +++ b/3D/Scenes/Props/Box_3D_Red.tscn @@ -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) diff --git a/3D/Scenes/Props/Box_3D_Yellow.tscn b/3D/Scenes/Props/Box_3D_Yellow.tscn index f9a0f3fb..6fbb94a4 100644 --- a/3D/Scenes/Props/Box_3D_Yellow.tscn +++ b/3D/Scenes/Props/Box_3D_Yellow.tscn @@ -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) diff --git a/3D/Scenes/Props/Camera_3D.tscn b/3D/Scenes/Props/Camera_3D.tscn index 91467f9c..7add20a6 100644 --- a/3D/Scenes/Props/Camera_3D.tscn +++ b/3D/Scenes/Props/Camera_3D.tscn @@ -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) diff --git a/3D/Scenes/Props/Capacitor_Mini_3D.tscn b/3D/Scenes/Props/Capacitor_Mini_3D.tscn index 2ded7c7a..f0aee3f9 100644 --- a/3D/Scenes/Props/Capacitor_Mini_3D.tscn +++ b/3D/Scenes/Props/Capacitor_Mini_3D.tscn @@ -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 diff --git a/3D/Scenes/Props/Wooden_Box.tscn b/3D/Scenes/Props/Wooden_Box.tscn index fd1f9a8e..6a93f52b 100644 --- a/3D/Scenes/Props/Wooden_Box.tscn +++ b/3D/Scenes/Props/Wooden_Box.tscn @@ -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) diff --git a/3D/Scenes/Props/barrel_3d.tscn b/3D/Scenes/Props/barrel_3d.tscn index da8b18a8..3be30230 100644 --- a/3D/Scenes/Props/barrel_3d.tscn +++ b/3D/Scenes/Props/barrel_3d.tscn @@ -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) diff --git a/ExternalMaterial/Explosion/Explosion_Procedural_423832.png.import b/ExternalMaterial/Explosion/Explosion_Procedural_423832.png.import index befa9f4f..4d258066 100644 --- a/ExternalMaterial/Explosion/Explosion_Procedural_423832.png.import +++ b/ExternalMaterial/Explosion/Explosion_Procedural_423832.png.import @@ -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 diff --git a/IsoTest/IsoMapTest2.tscn b/IsoTest/IsoMapTest2.tscn index 90976c06..6fa12403 100644 --- a/IsoTest/IsoMapTest2.tscn +++ b/IsoTest/IsoMapTest2.tscn @@ -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) diff --git a/Resources/Bullets/Explosion_3D.tres b/Resources/Bullets/Explosion_3D.tres new file mode 100644 index 00000000..869dc071 --- /dev/null +++ b/Resources/Bullets/Explosion_3D.tres @@ -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 = [] diff --git a/Resources/Bullets/Explosion_Harmless_3D.tres b/Resources/Bullets/Explosion_Harmless_3D.tres new file mode 100644 index 00000000..21d72868 --- /dev/null +++ b/Resources/Bullets/Explosion_Harmless_3D.tres @@ -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 = [] diff --git a/Resources/Bullets/Explosion_Harmless_Small_3D.tres b/Resources/Bullets/Explosion_Harmless_Small_3D.tres new file mode 100644 index 00000000..750f31fb --- /dev/null +++ b/Resources/Bullets/Explosion_Harmless_Small_3D.tres @@ -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 = [] diff --git a/Scenes/Weapons/Explosion_Bullet_3D.tscn b/Scenes/Weapons/Explosion_Bullet_3D.tscn new file mode 100644 index 00000000..92c49cc2 --- /dev/null +++ b/Scenes/Weapons/Explosion_Bullet_3D.tscn @@ -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"] diff --git a/Scenes/Weapons/Explosion_Bullet_Small_3D.tscn b/Scenes/Weapons/Explosion_Bullet_Small_3D.tscn new file mode 100644 index 00000000..017a0d1b --- /dev/null +++ b/Scenes/Weapons/Explosion_Bullet_Small_3D.tscn @@ -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"] diff --git a/Scripts/Actors/Destructible3D.cs b/Scripts/Actors/Destructible3D.cs index 81dd6db7..606c55bd 100644 --- a/Scripts/Actors/Destructible3D.cs +++ b/Scripts/Actors/Destructible3D.cs @@ -65,12 +65,10 @@ public partial class Destructible3D : StaticBody3D, IDestructible private void CreateExplosion() { if (ExplosionData == null) return; - - + var explosion = PoolingManager.Instance.SpawnBullet(ExplosionData); explosion.GlobalPosition = this.GlobalPosition; - explosion.Speed = 0; explosion.Initialize(ExplosionData.MakeBullet(new Vector2(this.GlobalPosition.X, this.GlobalPosition.Y))); diff --git a/Scripts/Components/Actors/PooledAnimatedSpritePlayer3D.cs b/Scripts/Components/Actors/PooledAnimatedSpritePlayer3D.cs new file mode 100644 index 00000000..18eeff68 --- /dev/null +++ b/Scripts/Components/Actors/PooledAnimatedSpritePlayer3D.cs @@ -0,0 +1,12 @@ +using Godot; + +namespace Cirno.Scripts.Components.Actors; + +public partial class PooledAnimatedSpritePlayer3D : AnimatedSprite3D +{ + public void PlayAnimation() + { + this.SetFrame(0); + this.Play(); + } +} \ No newline at end of file diff --git a/Scripts/Components/Actors/PooledAnimatedSpritePlayer3D.cs.uid b/Scripts/Components/Actors/PooledAnimatedSpritePlayer3D.cs.uid new file mode 100644 index 00000000..66633dc8 --- /dev/null +++ b/Scripts/Components/Actors/PooledAnimatedSpritePlayer3D.cs.uid @@ -0,0 +1 @@ +uid://cvk4jbit45sfi diff --git a/Scripts/Weapons/Bullet3D.cs b/Scripts/Weapons/Bullet3D.cs index d793933b..35362309 100644 --- a/Scripts/Weapons/Bullet3D.cs +++ b/Scripts/Weapons/Bullet3D.cs @@ -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(); } /// diff --git a/project.godot b/project.godot index 988b2413..f1652266 100644 --- a/project.godot +++ b/project.godot @@ -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"