diff --git a/scenes/characters/Player.cs b/scenes/characters/Player.cs index 6fc5faa..af7ca41 100644 --- a/scenes/characters/Player.cs +++ b/scenes/characters/Player.cs @@ -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("BoosterParticles"); + boosterLeftParticles = GetNode("BoosterLeftParticles"); + boosterRightParticles = GetNode("BoosterRightParticles"); deathAudioPlayer = GetNode("DeathAudioPlayer"); successAudioPlayer = GetNode("SuccessAudioPlayer"); rocketAudioPlayer = GetNode("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))); diff --git a/scenes/characters/booster_particles.tscn b/scenes/characters/booster_particles.tscn new file mode 100644 index 0000000..53b8414 --- /dev/null +++ b/scenes/characters/booster_particles.tscn @@ -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") diff --git a/scenes/characters/player.tscn b/scenes/characters/player.tscn index 15fbc1e..c2074ed 100644 --- a/scenes/characters/player.tscn +++ b/scenes/characters/player.tscn @@ -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