mirror of
https://github.com/marinho/godot-visual-effects.git
synced 2024-12-22 22:47:28 +08:00
Impact particles
This commit is contained in:
parent
77472b3c54
commit
e3e1929394
@ -3,25 +3,26 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://b8yqiftn6q2ij"
|
uid="uid://b8yqiftn6q2ij"
|
||||||
path="res://.godot/imported/circle_05.png-2d6c777c446ba2a583b61d30e52bc466.ctex"
|
path.s3tc="res://.godot/imported/circle_05.png-2d6c777c446ba2a583b61d30e52bc466.s3tc.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://addons/kenney_particle_pack/circle_05.png"
|
source_file="res://addons/kenney_particle_pack/circle_05.png"
|
||||||
dest_files=["res://.godot/imported/circle_05.png-2d6c777c446ba2a583b61d30e52bc466.ctex"]
|
dest_files=["res://.godot/imported/circle_05.png-2d6c777c446ba2a583b61d30e52bc466.s3tc.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
compress/mode=0
|
compress/mode=2
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
mipmaps/generate=false
|
mipmaps/generate=true
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
@ -31,4 +32,4 @@ process/normal_map_invert_y=false
|
|||||||
process/hdr_as_srgb=false
|
process/hdr_as_srgb=false
|
||||||
process/hdr_clamp_exposure=false
|
process/hdr_clamp_exposure=false
|
||||||
process/size_limit=0
|
process/size_limit=0
|
||||||
detect_3d/compress_to=1
|
detect_3d/compress_to=0
|
||||||
|
@ -3,25 +3,26 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://cpqufbjs2rf5t"
|
uid="uid://cpqufbjs2rf5t"
|
||||||
path="res://.godot/imported/muzzle_01.png-6b5b53ab7ff581d37d9574d2b01cae58.ctex"
|
path.s3tc="res://.godot/imported/muzzle_01.png-6b5b53ab7ff581d37d9574d2b01cae58.s3tc.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://addons/kenney_particle_pack/muzzle_01.png"
|
source_file="res://addons/kenney_particle_pack/muzzle_01.png"
|
||||||
dest_files=["res://.godot/imported/muzzle_01.png-6b5b53ab7ff581d37d9574d2b01cae58.ctex"]
|
dest_files=["res://.godot/imported/muzzle_01.png-6b5b53ab7ff581d37d9574d2b01cae58.s3tc.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
compress/mode=0
|
compress/mode=2
|
||||||
compress/high_quality=false
|
compress/high_quality=false
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
mipmaps/generate=false
|
mipmaps/generate=true
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
@ -31,4 +32,4 @@ process/normal_map_invert_y=false
|
|||||||
process/hdr_as_srgb=false
|
process/hdr_as_srgb=false
|
||||||
process/hdr_clamp_exposure=false
|
process/hdr_clamp_exposure=false
|
||||||
process/size_limit=0
|
process/size_limit=0
|
||||||
detect_3d/compress_to=1
|
detect_3d/compress_to=0
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=11 format=3 uid="uid://chomobsn1vdo4"]
|
[gd_scene load_steps=12 format=3 uid="uid://chomobsn1vdo4"]
|
||||||
|
|
||||||
[ext_resource type="Environment" uid="uid://dxrk0u62aekxt" path="res://environments/black-environment.tres" id="1_k1rat"]
|
[ext_resource type="Environment" uid="uid://dxrk0u62aekxt" path="res://environments/black-environment.tres" id="1_k1rat"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cxj4cf67il71y" path="res://particles/smoke.tscn" id="1_vs4eb"]
|
[ext_resource type="PackedScene" uid="uid://cxj4cf67il71y" path="res://particles/smoke.tscn" id="1_vs4eb"]
|
||||||
@ -8,6 +8,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://b2dthk7xytysh" path="res://particles/shield.tscn" id="5_iqqai"]
|
[ext_resource type="PackedScene" uid="uid://b2dthk7xytysh" path="res://particles/shield.tscn" id="5_iqqai"]
|
||||||
[ext_resource type="PackedScene" uid="uid://ck5vuhi3tffgl" path="res://particles/sparks.tscn" id="6_n8y86"]
|
[ext_resource type="PackedScene" uid="uid://ck5vuhi3tffgl" path="res://particles/sparks.tscn" id="6_n8y86"]
|
||||||
[ext_resource type="PackedScene" uid="uid://1nbihtdf4hnv" path="res://particles/rain.tscn" id="8_pqidy"]
|
[ext_resource type="PackedScene" uid="uid://1nbihtdf4hnv" path="res://particles/rain.tscn" id="8_pqidy"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://jyk4uwcupa50" path="res://particles/impact.tscn" id="9_x76w5"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_njwlo"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_njwlo"]
|
||||||
shading_mode = 0
|
shading_mode = 0
|
||||||
@ -53,8 +54,21 @@ visible = false
|
|||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
[node name="Shield" parent="." instance=ExtResource("5_iqqai")]
|
[node name="Shield" parent="." instance=ExtResource("5_iqqai")]
|
||||||
|
visible = false
|
||||||
|
|
||||||
[node name="Sparks" parent="." instance=ExtResource("6_n8y86")]
|
[node name="Sparks" parent="." instance=ExtResource("6_n8y86")]
|
||||||
visible = false
|
visible = false
|
||||||
|
|
||||||
[node name="Rain" parent="." instance=ExtResource("8_pqidy")]
|
[node name="Rain" parent="." instance=ExtResource("8_pqidy")]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Impact" parent="." instance=ExtResource("9_x76w5")]
|
||||||
|
|
||||||
|
[node name="Shockwave" type="Node3D" parent="."]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Electricity" type="Node3D" parent="."]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Implosion" type="Node3D" parent="."]
|
||||||
|
visible = false
|
||||||
|
75
particles/impact.tscn
Normal file
75
particles/impact.tscn
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
[gd_scene load_steps=13 format=3 uid="uid://jyk4uwcupa50"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cpqufbjs2rf5t" path="res://addons/kenney_particle_pack/muzzle_01.png" id="1_nj335"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b8yqiftn6q2ij" path="res://addons/kenney_particle_pack/circle_05.png" id="2_6unvo"]
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id="Curve_lqnej"]
|
||||||
|
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.370492, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
|
||||||
|
point_count = 3
|
||||||
|
|
||||||
|
[sub_resource type="CurveTexture" id="CurveTexture_rymgb"]
|
||||||
|
curve = SubResource("Curve_lqnej")
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id="Curve_mr68g"]
|
||||||
|
_data = [Vector2(0, 0.521682), 0.0, 0.0, 0, 0, Vector2(0.144262, 1), 0.0, 0.0, 0, 0]
|
||||||
|
point_count = 2
|
||||||
|
|
||||||
|
[sub_resource type="CurveTexture" id="CurveTexture_7xpum"]
|
||||||
|
curve = SubResource("Curve_mr68g")
|
||||||
|
|
||||||
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_s3tbj"]
|
||||||
|
gravity = Vector3(0, 0, 0)
|
||||||
|
scale_curve = SubResource("CurveTexture_7xpum")
|
||||||
|
alpha_curve = SubResource("CurveTexture_rymgb")
|
||||||
|
sub_emitter_mode = 2
|
||||||
|
sub_emitter_amount_at_end = 1
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ky36s"]
|
||||||
|
transparency = 1
|
||||||
|
blend_mode = 1
|
||||||
|
vertex_color_use_as_albedo = true
|
||||||
|
albedo_color = Color(1, 1, 1, 0.0392157)
|
||||||
|
albedo_texture = ExtResource("1_nj335")
|
||||||
|
rim_enabled = true
|
||||||
|
billboard_mode = 3
|
||||||
|
billboard_keep_scale = true
|
||||||
|
particles_anim_h_frames = 1
|
||||||
|
particles_anim_v_frames = 1
|
||||||
|
particles_anim_loop = false
|
||||||
|
|
||||||
|
[sub_resource type="QuadMesh" id="QuadMesh_ot0ot"]
|
||||||
|
material = SubResource("StandardMaterial3D_ky36s")
|
||||||
|
center_offset = Vector3(0, 0.4, 0)
|
||||||
|
|
||||||
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_iv2ux"]
|
||||||
|
direction = Vector3(0, 2, 0)
|
||||||
|
initial_velocity_min = 3.0
|
||||||
|
initial_velocity_max = 3.0
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6ojok"]
|
||||||
|
transparency = 1
|
||||||
|
vertex_color_use_as_albedo = true
|
||||||
|
albedo_texture = ExtResource("2_6unvo")
|
||||||
|
billboard_mode = 3
|
||||||
|
billboard_keep_scale = true
|
||||||
|
particles_anim_h_frames = 1
|
||||||
|
particles_anim_v_frames = 1
|
||||||
|
particles_anim_loop = false
|
||||||
|
|
||||||
|
[sub_resource type="QuadMesh" id="QuadMesh_pmnps"]
|
||||||
|
material = SubResource("StandardMaterial3D_6ojok")
|
||||||
|
size = Vector2(0.1, 0.1)
|
||||||
|
|
||||||
|
[node name="Impact" type="Node3D"]
|
||||||
|
|
||||||
|
[node name="GPUParticles3D" type="GPUParticles3D" parent="."]
|
||||||
|
amount = 10
|
||||||
|
sub_emitter = NodePath("../GPUParticles3D2")
|
||||||
|
explosiveness = 1.0
|
||||||
|
fixed_fps = 60
|
||||||
|
process_material = SubResource("ParticleProcessMaterial_s3tbj")
|
||||||
|
draw_pass_1 = SubResource("QuadMesh_ot0ot")
|
||||||
|
|
||||||
|
[node name="GPUParticles3D2" type="GPUParticles3D" parent="."]
|
||||||
|
process_material = SubResource("ParticleProcessMaterial_iv2ux")
|
||||||
|
draw_pass_1 = SubResource("QuadMesh_pmnps")
|
@ -64,8 +64,9 @@ material = SubResource("StandardMaterial3D_lmrnj")
|
|||||||
size = Vector2(1.5, 1.5)
|
size = Vector2(1.5, 1.5)
|
||||||
|
|
||||||
[sub_resource type="Curve" id="Curve_8kor2"]
|
[sub_resource type="Curve" id="Curve_8kor2"]
|
||||||
|
min_value = -360.0
|
||||||
max_value = 360.0
|
max_value = 360.0
|
||||||
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 360), 0.0, 0.0, 0, 0]
|
_data = [Vector2(0, -360), 0.0, 0.0, 0, 0, Vector2(1, 360), 0.0, 0.0, 0, 0]
|
||||||
point_count = 2
|
point_count = 2
|
||||||
|
|
||||||
[sub_resource type="CurveTexture" id="CurveTexture_7lrlq"]
|
[sub_resource type="CurveTexture" id="CurveTexture_7lrlq"]
|
||||||
@ -83,17 +84,16 @@ curve = SubResource("Curve_jwnch")
|
|||||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_eugrd"]
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_eugrd"]
|
||||||
particle_flag_align_y = true
|
particle_flag_align_y = true
|
||||||
particle_flag_rotate_y = true
|
particle_flag_rotate_y = true
|
||||||
angle_max = 1.0
|
|
||||||
angle_curve = SubResource("CurveTexture_7lrlq")
|
angle_curve = SubResource("CurveTexture_7lrlq")
|
||||||
direction = Vector3(0, 0, 0)
|
direction = Vector3(0, 0, 0)
|
||||||
angular_velocity_min = 0.1
|
angular_velocity_min = 0.1
|
||||||
angular_velocity_max = 0.1
|
angular_velocity_max = 0.1
|
||||||
angular_velocity_curve = SubResource("CurveTexture_1uygt")
|
angular_velocity_curve = SubResource("CurveTexture_1uygt")
|
||||||
gravity = Vector3(0, 0, 0)
|
gravity = Vector3(0, 0, 0)
|
||||||
color = Color(0, 0.647059, 1, 0.501961)
|
color = Color(0.796078, 0.760784, 1, 0.501961)
|
||||||
|
|
||||||
[sub_resource type="Gradient" id="Gradient_q8hwq"]
|
[sub_resource type="Gradient" id="Gradient_q8hwq"]
|
||||||
offsets = PackedFloat32Array(0.58363, 0.6121, 0.651246)
|
offsets = PackedFloat32Array(0.587189, 0.6121, 0.629893)
|
||||||
colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0)
|
colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0)
|
||||||
|
|
||||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_irpch"]
|
[sub_resource type="GradientTexture2D" id="GradientTexture2D_irpch"]
|
||||||
@ -106,6 +106,7 @@ fill_from = Vector2(0.5, 0.5)
|
|||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6lgl3"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6lgl3"]
|
||||||
transparency = 1
|
transparency = 1
|
||||||
blend_mode = 1
|
blend_mode = 1
|
||||||
|
vertex_color_use_as_albedo = true
|
||||||
albedo_texture = SubResource("GradientTexture2D_irpch")
|
albedo_texture = SubResource("GradientTexture2D_irpch")
|
||||||
billboard_keep_scale = true
|
billboard_keep_scale = true
|
||||||
|
|
||||||
@ -115,7 +116,6 @@ size = Vector2(1.2, 1.2)
|
|||||||
orientation = 0
|
orientation = 0
|
||||||
|
|
||||||
[node name="Shield" type="Node3D"]
|
[node name="Shield" type="Node3D"]
|
||||||
visible = false
|
|
||||||
|
|
||||||
[node name="Sphere" type="GPUParticles3D" parent="."]
|
[node name="Sphere" type="GPUParticles3D" parent="."]
|
||||||
amount = 1
|
amount = 1
|
||||||
|
@ -1,68 +1,65 @@
|
|||||||
using System;
|
using System;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace GodotVisualEffectsToolkit
|
/**
|
||||||
|
* MultiParticles : Node3D
|
||||||
|
*
|
||||||
|
* This class turns possible to control multiple particles in sync.
|
||||||
|
* Inspired by https://www.reddit.com/r/godot/comments/181ui9c/comment/kaewcca/?context=3
|
||||||
|
*/
|
||||||
|
public partial class MultiParticles : Node3D
|
||||||
{
|
{
|
||||||
/**
|
[Export]
|
||||||
* MultiParticles : Node3D
|
public bool Emitting = true;
|
||||||
*
|
|
||||||
* This class turns possible to control multiple particles in sync.
|
[Export]
|
||||||
* Inspired by https://www.reddit.com/r/godot/comments/181ui9c/comment/kaewcca/?context=3
|
public bool OneShot = false;
|
||||||
*/
|
|
||||||
public partial class MultiParticles : Node3D
|
[Export]
|
||||||
|
public Godot.Collections.Array<GpuParticles3D> Particles;
|
||||||
|
|
||||||
|
double Lifetime = 0.0f;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
[Export]
|
if (Emitting)
|
||||||
public bool Emitting = true;
|
|
||||||
|
|
||||||
[Export]
|
|
||||||
public bool OneShot = false;
|
|
||||||
|
|
||||||
[Export]
|
|
||||||
public Godot.Collections.Array<GpuParticles3D> Particles;
|
|
||||||
|
|
||||||
double Lifetime = 0.0f;
|
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
{
|
||||||
if (Emitting)
|
StartEmitters();
|
||||||
{
|
|
||||||
StartEmitters();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GetLifetime()
|
void GetLifetime()
|
||||||
|
{
|
||||||
|
foreach (var particle in Particles)
|
||||||
{
|
{
|
||||||
foreach (var particle in Particles)
|
if (particle.Lifetime > Lifetime)
|
||||||
{
|
{
|
||||||
if (particle.Lifetime > Lifetime)
|
Lifetime = particle.Lifetime;
|
||||||
{
|
|
||||||
Lifetime = particle.Lifetime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void StartEmitters()
|
|
||||||
{
|
|
||||||
GetLifetime();
|
|
||||||
|
|
||||||
foreach (var particle in Particles)
|
|
||||||
particle.Emitting = true;
|
|
||||||
|
|
||||||
await ToSignal(GetTree().CreateTimer(Lifetime), SceneTreeTimer.SignalName.Timeout);
|
|
||||||
DisposeOfEmitters();
|
|
||||||
|
|
||||||
if (!OneShot)
|
|
||||||
{
|
|
||||||
StartEmitters();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DisposeOfEmitters()
|
|
||||||
{
|
|
||||||
foreach (var particle in Particles)
|
|
||||||
{
|
|
||||||
particle.Emitting = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void StartEmitters()
|
||||||
|
{
|
||||||
|
GetLifetime();
|
||||||
|
|
||||||
|
foreach (var particle in Particles)
|
||||||
|
particle.Emitting = true;
|
||||||
|
|
||||||
|
await ToSignal(GetTree().CreateTimer(Lifetime), SceneTreeTimer.SignalName.Timeout);
|
||||||
|
DisposeOfEmitters();
|
||||||
|
|
||||||
|
if (!OneShot)
|
||||||
|
{
|
||||||
|
StartEmitters();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisposeOfEmitters()
|
||||||
|
{
|
||||||
|
foreach (var particle in Particles)
|
||||||
|
{
|
||||||
|
particle.Emitting = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user