2.17 introducing particles
This commit is contained in:
parent
08553f798f
commit
097a090b24
3 changed files with 66 additions and 1 deletions
|
@ -10,12 +10,19 @@ public partial class Player : RigidBody3D
|
|||
private Vector3 ZLeft;
|
||||
private Vector3 ZRight;
|
||||
|
||||
private GpuParticles3D boosterParticles;
|
||||
private GpuParticles3D boosterLeftParticles;
|
||||
private GpuParticles3D boosterRightParticles;
|
||||
|
||||
private AudioStreamPlayer deathAudioPlayer;
|
||||
private AudioStreamPlayer successAudioPlayer;
|
||||
private AudioStreamPlayer3D rocketAudioPlayer;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
boosterParticles = GetNode<GpuParticles3D>("BoosterParticles");
|
||||
boosterLeftParticles = GetNode<GpuParticles3D>("BoosterLeftParticles");
|
||||
boosterRightParticles = GetNode<GpuParticles3D>("BoosterRightParticles");
|
||||
deathAudioPlayer = GetNode<AudioStreamPlayer>("DeathAudioPlayer");
|
||||
successAudioPlayer = GetNode<AudioStreamPlayer>("SuccessAudioPlayer");
|
||||
rocketAudioPlayer = GetNode<AudioStreamPlayer3D>("RocketAudioPlayer");
|
||||
|
@ -28,17 +35,25 @@ public partial class Player : RigidBody3D
|
|||
float fd = (float)delta;
|
||||
if (Input.IsActionPressed("boost")){
|
||||
ApplyCentralForce(Basis.Y * fd * thrust);
|
||||
boosterParticles.Emitting = true;
|
||||
if (!rocketAudioPlayer.Playing){
|
||||
rocketAudioPlayer.Play();
|
||||
}
|
||||
} else {
|
||||
rocketAudioPlayer.Stop();
|
||||
boosterParticles.Emitting = false;
|
||||
}
|
||||
if (Input.IsActionPressed("rotate_left")){
|
||||
ApplyTorque(ZLeft * fd);
|
||||
boosterLeftParticles.Emitting = true;
|
||||
} else {
|
||||
boosterLeftParticles.Emitting = false;
|
||||
}
|
||||
if (Input.IsActionPressed("rotate_right")){
|
||||
ApplyTorque(ZRight * fd);
|
||||
boosterRightParticles.Emitting = true;
|
||||
} else {
|
||||
boosterRightParticles.Emitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,6 +73,7 @@ public partial class Player : RigidBody3D
|
|||
private void CrashSequence(){
|
||||
deathAudioPlayer.Play();
|
||||
rocketAudioPlayer.Stop();
|
||||
boosterParticles.Emitting = false;
|
||||
Tween tween = CreateTween();
|
||||
tween.TweenInterval(2.5);
|
||||
tween.TweenCallback(Callable.From(() => DeferredCalls.ReloadCurrentScene(this)));
|
||||
|
|
36
scenes/characters/booster_particles.tscn
Normal file
36
scenes/characters/booster_particles.tscn
Normal file
|
@ -0,0 +1,36 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://ux6ivcx1ovdp"]
|
||||
|
||||
[sub_resource type="Curve" id="Curve_w7ove"]
|
||||
_data = [Vector2(0, 1), 0.0, 1.40451, 0, 0, Vector2(1, 0), -2.21649, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_0capg"]
|
||||
curve = SubResource("Curve_w7ove")
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_fgg2i"]
|
||||
direction = Vector3(0, -1, 0)
|
||||
spread = 15.0
|
||||
initial_velocity_min = 2.0
|
||||
initial_velocity_max = 4.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
damping_min = 9.0
|
||||
damping_max = 9.0
|
||||
scale_curve = SubResource("CurveTexture_0capg")
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6pwbh"]
|
||||
emission_enabled = true
|
||||
emission = Color(1, 1, 1, 1)
|
||||
emission_energy_multiplier = 2.0
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_atjxn"]
|
||||
material = SubResource("StandardMaterial3D_6pwbh")
|
||||
radius = 0.1
|
||||
height = 0.2
|
||||
radial_segments = 32
|
||||
rings = 16
|
||||
|
||||
[node name="BoosterParticles" type="GPUParticles3D"]
|
||||
amount = 32
|
||||
lifetime = 0.5
|
||||
process_material = SubResource("ParticleProcessMaterial_fgg2i")
|
||||
draw_pass_1 = SubResource("SphereMesh_atjxn")
|
|
@ -1,9 +1,10 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://cuduv6fwqtocs"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://cuduv6fwqtocs"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/characters/Player.cs" id="1_fr1bo"]
|
||||
[ext_resource type="AudioStream" uid="uid://nsq05kpsix83" path="res://resources/audio/SFX - Death Explosion.ogg" id="2_ml1je"]
|
||||
[ext_resource type="AudioStream" uid="uid://cr4ckjeqxa5xe" path="res://resources/audio/SFX - Success.ogg" id="3_xmihe"]
|
||||
[ext_resource type="AudioStream" uid="uid://dyf7x2qy7lww" path="res://resources/audio/SFX - Main engine thrust.ogg" id="4_204bm"]
|
||||
[ext_resource type="PackedScene" uid="uid://ux6ivcx1ovdp" path="res://scenes/characters/booster_particles.tscn" id="5_q1ic3"]
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_dk8lw"]
|
||||
|
||||
|
@ -33,3 +34,15 @@ stream = ExtResource("3_xmihe")
|
|||
|
||||
[node name="RocketAudioPlayer" type="AudioStreamPlayer3D" parent="."]
|
||||
stream = ExtResource("4_204bm")
|
||||
|
||||
[node name="BoosterParticles" parent="." instance=ExtResource("5_q1ic3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
|
||||
emitting = false
|
||||
|
||||
[node name="BoosterLeftParticles" parent="." instance=ExtResource("5_q1ic3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.939693, -0.34202, 0, 0.34202, 0.939693, 0, -1, -0.4)
|
||||
emitting = false
|
||||
|
||||
[node name="BoosterRightParticles" parent="." instance=ExtResource("5_q1ic3")]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.939693, 0.34202, 0, -0.34202, 0.939693, 0, -1, 0.4)
|
||||
emitting = false
|
||||
|
|
Loading…
Add table
Reference in a new issue