Missile Side Thrusters and new Shader path

Changed the missile model to also include thrusters for rotational purposes and gave them the same exhaust shader.
Each shader is a unique instance and displayed thrusts can be set with set_X_rotational_thrust(), set_Y_rotational_thrust() and set_main_engine_thrust() in the missile root respectively.

Also added a second missile in the space scene just for debugging purposes.
main
Peery 2 years ago
parent c8d0ac802a
commit 9b91d2c8a9

@ -0,0 +1 @@
/home/peery/Documents/private/Creative_Products/My_Blender/Models/Usable_Models/Assets/missile/missile.blend

@ -3,24 +3,98 @@ extends Spatial
onready var exhaust_node = $Exhaust;
func change_engine_power(power):
func _set_thruster_thrust(node: MeshInstance, power):
#print("Node: ", node.name)
var MAX_POWER = 10;
var exhausts = ["Exhaust", "Exhaust2", "Exhaust3", "Exhaust4"];
print("Changing missile exhaust to: ", power);
node.get_surface_material(0).set_shader_param("power", clamp(power, .0, MAX_POWER));
var particle_node: Particles = node.get_node("./Particles");
if power < 2.0:
if power == 0.0:
node.set_visible(false);
particle_node.set_emitting(false);
else:
node.set_visible(true);
particle_node.set_emitting(true);
# Set the visual main engine flare from 0.0 to 10.0
# 0.0 turns off all engine effects
func set_main_engine_thrust(power):
var exhausts = exhaust_node.get_node("Main").get_children();
print("Changing main exhaust to: ", power);
for e in exhausts:
var node: MeshInstance = exhaust_node.get_node("./"+e);
node.get_active_material(0).set_shader_param("power", clamp(power, .0, MAX_POWER));
var particle_node: Particles = node.get_node("./Particles");
if power < 2.0:
if power == 0.0:
node.set_visible(false);
particle_node.set_emitting(false);
else:
node.set_visible(true);
particle_node.set_emitting(true);
for node in exhausts:
self._set_thruster_thrust(node, power);
# Set the visual rotational engine flare from -10.0 to 10.0
# Negative power visualizes downwards, Positive upwards and 0.0 turns all X thrusters off
func set_X_rotational_thrust(power):
var MAX_POWER = 10;
var up_rotation_thrusters = [exhaust_node.get_node("FrontThrusters/ThrusterBottom"), exhaust_node.get_node("RearThrusters/ThrusterTop")];
var down_rotation_thrusters = [exhaust_node.get_node("FrontThrusters/ThrusterTop"), exhaust_node.get_node("RearThrusters/ThrusterBottom")];
if power > 0.0:
print("Changing rotation thrust upwards to: ", power);
for node in up_rotation_thrusters:
self._set_thruster_thrust(node, power);
for node in down_rotation_thrusters:
self._set_thruster_thrust(node, 0.0);
elif power < 0.0:
print("Changing rotation thrust downwards to: ", power);
for node in down_rotation_thrusters:
self._set_thruster_thrust(node, -1 * power);
for node in up_rotation_thrusters:
self._set_thruster_thrust(node, 0.0);
else:
print("Turning X rotation thrusters off");
for node in up_rotation_thrusters+down_rotation_thrusters:
self._set_thruster_thrust(node, 0.0);
# Set the visual rotational engine flare from -10.0 to 10.0
# Negative power visualizes left, Positive right and 0.0 turns all Y thrusters off
func set_Y_rotational_thrust(power):
var MAX_POWER = 10;
var left_rotation_thrusters = [exhaust_node.get_node("FrontThrusters/ThrusterLeft"), exhaust_node.get_node("RearThrusters/ThrusterRight")];
var right_rotation_thrusters = [exhaust_node.get_node("FrontThrusters/ThrusterRight"), exhaust_node.get_node("RearThrusters/ThrusterLeft")];
if power > 0.0:
print("Changing rotation thrust right to: ", power);
for node in right_rotation_thrusters:
self._set_thruster_thrust(node, power);
for node in left_rotation_thrusters:
self._set_thruster_thrust(node, 0.0);
elif power < 0.0:
print("Changing rotation thrust left to: ", power);
for node in left_rotation_thrusters:
self._set_thruster_thrust(node, -1 * power);
for node in right_rotation_thrusters:
self._set_thruster_thrust(node, 0.0);
else:
print("Turning Y rotation thrusters off");
for node in right_rotation_thrusters+left_rotation_thrusters:
self._set_thruster_thrust(node, 0.0);
func _ready():
change_engine_power(0.0);
set_main_engine_thrust(5.0);
set_X_rotational_thrust(10.0);
set_Y_rotational_thrust(10.0);
var time_passed = 0.0;
var curr_rot_power = 10.0;
var curr_main_power = 0.0;
func _physics_process(delta):
time_passed += delta;
if time_passed > 1:
print("Setting rotation X to 5.0");
set_X_rotational_thrust(curr_rot_power);
set_Y_rotational_thrust(curr_rot_power);
set_main_engine_thrust(curr_main_power);
curr_rot_power *= -1;
curr_main_power += 1;
if curr_main_power > 10.0:
curr_main_power = 0.0;
time_passed = 0.0;

@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=2]
[gd_scene load_steps=24 format=2]
[ext_resource path="res://assets/entities/missile/missile.glb" type="PackedScene" id=1]
[ext_resource path="res://assets/entities/missile/missile_albedo.png" type="Texture" id=2]
@ -13,20 +13,17 @@ roughness = 0.41
[sub_resource type="CapsuleShape" id=1]
height = 10.1286
[sub_resource type="ShaderMaterial" id=8]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/hot_color = Color( 0.9, 0.9, 9, 0.5 )
shader_param/cold_color = Color( 1, 1, 1, 0 )
shader_param/power = 1.0
[sub_resource type="SphereMesh" id=9]
material = SubResource( 8 )
radius = 0.35
height = 0.5
radial_segments = 128
rings = 64
[sub_resource type="ShaderMaterial" id=14]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ParticlesMaterial" id=3]
emission_shape = 1
emission_sphere_radius = 0.25
@ -63,26 +60,87 @@ height = 0.05
radial_segments = 32
rings = 16
[sub_resource type="ShaderMaterial" id=15]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ShaderMaterial" id=16]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ShaderMaterial" id=17]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ShaderMaterial" id=18]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ShaderMaterial" id=19]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ShaderMaterial" id=20]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ShaderMaterial" id=21]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ShaderMaterial" id=10]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ShaderMaterial" id=11]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ShaderMaterial" id=12]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[sub_resource type="ShaderMaterial" id=13]
shader = ExtResource( 4 )
shader_param/ANIM_SPEED = 100.0
shader_param/power = 1.0
[node name="missile" instance=ExtResource( 1 )]
script = ExtResource( 3 )
[node name="missile body" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.851097 )
material/0 = SubResource( 2 )
[node name="RigidBody" type="RigidBody" parent="." index="1"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.688615 )
[node name="CollisionShape" type="CollisionShape" parent="RigidBody" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.371096 )
shape = SubResource( 1 )
[node name="Exhaust" type="Spatial" parent="." index="2"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -4.901 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5.74946 )
[node name="Exhaust" type="MeshInstance" parent="Exhaust" index="0"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.5, 0.5, 0.1 )
[node name="Main" type="Spatial" parent="Exhaust" index="0"]
[node name="MainThrusterTL" type="MeshInstance" parent="Exhaust/Main" index="0"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.5, 0.5, 0.0999999 )
mesh = SubResource( 9 )
skeleton = NodePath("../..")
material/0 = SubResource( 14 )
[node name="Particles" type="Particles" parent="Exhaust/Exhaust" index="0"]
[node name="Particles" type="Particles" parent="Exhaust/Main/MainThrusterTL" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
@ -92,42 +150,177 @@ visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="Exhaust2" type="MeshInstance" parent="Exhaust" index="1"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.5, 0.5, 0.1 )
mesh = SubResource( 9 )
skeleton = NodePath("../Exhaust")
[node name="Particles" type="Particles" parent="Exhaust/Exhaust2" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="Exhaust3" type="MeshInstance" parent="Exhaust" index="2"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.5, -0.5, 0.1 )
mesh = SubResource( 9 )
skeleton = NodePath("../Exhaust2")
[node name="Particles" type="Particles" parent="Exhaust/Exhaust3" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="Exhaust4" type="MeshInstance" parent="Exhaust" index="3"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.5, -0.5, 0.1 )
[node name="MainThrusterTR" type="MeshInstance" parent="Exhaust/Main" index="1"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.5, 0.5, 0.0999999 )
mesh = SubResource( 9 )
skeleton = NodePath(".")
material/0 = SubResource( 15 )
[node name="Particles" type="Particles" parent="Exhaust/Exhaust4" index="0"]
[node name="Particles" type="Particles" parent="Exhaust/Main/MainThrusterTR" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="MainThrusterBL" type="MeshInstance" parent="Exhaust/Main" index="2"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.5, -0.5, 0.0999999 )
mesh = SubResource( 9 )
skeleton = NodePath(".")
material/0 = SubResource( 16 )
[node name="Particles" type="Particles" parent="Exhaust/Main/MainThrusterBL" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="MainThrusterBR" type="MeshInstance" parent="Exhaust/Main" index="3"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.5, -0.5, 0.0999999 )
mesh = SubResource( 9 )
skeleton = NodePath(".")
material/0 = SubResource( 17 )
[node name="Particles" type="Particles" parent="Exhaust/Main/MainThrusterBR" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="RearThrusters" type="Spatial" parent="Exhaust" index="1"]
[node name="ThrusterLeft" type="MeshInstance" parent="Exhaust/RearThrusters" index="0"]
transform = Transform( -8.74228e-09, -0.2, 0, 0.2, -8.74228e-09, 0, 0, 0, 0.2, 1.02839, 0, 2.9246 )
mesh = SubResource( 9 )
skeleton = NodePath("../../Main/MainThrusterTL")
material/0 = SubResource( 18 )
[node name="Particles" type="Particles" parent="Exhaust/RearThrusters/ThrusterLeft" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="ThrusterRight" type="MeshInstance" parent="Exhaust/RearThrusters" index="1"]
transform = Transform( -8.74228e-09, 0.2, 0, -0.2, -8.74228e-09, 0, 0, 0, 0.2, -1.028, 0, 2.925 )
mesh = SubResource( 9 )
skeleton = NodePath("../../Main/MainThrusterTL")
material/0 = SubResource( 19 )
[node name="Particles" type="Particles" parent="Exhaust/RearThrusters/ThrusterRight" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="ThrusterTop" type="MeshInstance" parent="Exhaust/RearThrusters" index="2"]
transform = Transform( -0.2, -1.74846e-08, 0, 1.74846e-08, -0.2, 0, 0, 0, 0.2, 0, 1.028, 2.925 )
mesh = SubResource( 9 )
skeleton = NodePath("../../Main/MainThrusterTL")
material/0 = SubResource( 20 )
[node name="Particles" type="Particles" parent="Exhaust/RearThrusters/ThrusterTop" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="ThrusterBottom" type="MeshInstance" parent="Exhaust/RearThrusters" index="3"]
transform = Transform( 0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, -1.028, 2.925 )
mesh = SubResource( 9 )
skeleton = NodePath("../../Main/MainThrusterTL")
material/0 = SubResource( 21 )
[node name="Particles" type="Particles" parent="Exhaust/RearThrusters/ThrusterBottom" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="FrontThrusters" type="Spatial" parent="Exhaust" index="2"]
[node name="ThrusterLeft" type="MeshInstance" parent="Exhaust/FrontThrusters" index="0"]
transform = Transform( -8.74228e-09, -0.2, 0, 0.2, -8.74228e-09, 0, 0, 0, 0.2, 0.631258, 0, 8.90092 )
mesh = SubResource( 9 )
skeleton = NodePath("../../Main/MainThrusterTL")
material/0 = SubResource( 10 )
[node name="Particles" type="Particles" parent="Exhaust/FrontThrusters/ThrusterLeft" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="ThrusterRight" type="MeshInstance" parent="Exhaust/FrontThrusters" index="1"]
transform = Transform( -8.74228e-09, 0.2, 0, -0.2, -8.74228e-09, 0, 0, 0, 0.2, -0.631, 0, 8.901 )
mesh = SubResource( 9 )
skeleton = NodePath("../../Main/MainThrusterTL")
material/0 = SubResource( 11 )
[node name="Particles" type="Particles" parent="Exhaust/FrontThrusters/ThrusterRight" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="ThrusterBottom" type="MeshInstance" parent="Exhaust/FrontThrusters" index="2"]
transform = Transform( 0.2, -3.49691e-08, 0, 3.49691e-08, 0.2, 0, 0, 0, 0.2, 0, -0.631, 8.901 )
mesh = SubResource( 9 )
skeleton = NodePath("../../Main/MainThrusterTL")
material/0 = SubResource( 12 )
[node name="Particles" type="Particles" parent="Exhaust/FrontThrusters/ThrusterBottom" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false
amount = 50
lifetime = 3.0
visibility_aabb = AABB( nan, 0.05694, -7.38708, 0.867362, 0.904675, 14.7742 )
process_material = SubResource( 3 )
draw_pass_1 = SubResource( 4 )
[node name="ThrusterTop" type="MeshInstance" parent="Exhaust/FrontThrusters" index="3"]
transform = Transform( -0.2, 1.74846e-08, 0, -1.74846e-08, -0.2, 0, 0, 0, 0.2, 0, 0.631, 8.901 )
mesh = SubResource( 9 )
skeleton = NodePath("../../Main/MainThrusterTL")
material/0 = SubResource( 13 )
[node name="Particles" type="Particles" parent="Exhaust/FrontThrusters/ThrusterTop" index="0"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-08, 0, -8.74228e-08, -1, 0, 0, 0 )
cast_shadow = 0
emitting = false

@ -0,0 +1,10 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
[ext_resource path="res://scenes/entities/missiles/missile_exhaust.gdshader" type="Shader" id=1]
[resource]
shader = ExtResource( 1 )
shader_param/ANIM_SPEED = 100.0
shader_param/hot_color = Color( 0.9, 0.9, 9, 0.5 )
shader_param/cold_color = Color( 1, 1, 1, 0 )
shader_param/power = 1.0

@ -33,7 +33,10 @@ script = ExtResource( 3 )
mesh = SubResource( 3 )
[node name="missile" parent="entities" instance=ExtResource( 4 )]
transform = Transform( 0.860022, 0, -0.510258, 0, 1, 0, 0.510258, 0, 0.860022, -2.93378, 8.26498, -11.9562 )
transform = Transform( 0.965223, 0, -0.261431, 0.176115, 0.739043, 0.65023, 0.193209, -0.673658, 0.713342, -2.93378, 8.26498, -11.9562 )
[node name="missile2" parent="entities" instance=ExtResource( 4 )]
transform = Transform( 0.881144, 0.176115, -0.438829, -0.436702, 0.65898, -0.612404, 0.181326, 0.731252, 0.657566, 9.71882, 6.0822, -4.97612 )
[node name="lighting" type="Node" parent="."]

Loading…
Cancel
Save