|
|
|
@ -11,7 +11,7 @@ var MISSILE_ID = "UNKNOWN";
|
|
|
|
|
var is_operational: bool = true; # if the missile is operational
|
|
|
|
|
var has_fuel: bool = true;
|
|
|
|
|
|
|
|
|
|
var turn_instruction: Vector3 = Vector3(0, 1, 0); # vector of (X, Y, Z) possible rotational thrust to apply (0.0 to 1.0 for full turn)
|
|
|
|
|
var turn_instruction: Vector3 = Vector3(0, 0, 0); # vector of (X, Y, Z) possible rotational thrust to apply (0.0 to 1.0 for full turn)
|
|
|
|
|
var thrust_instruction: float = 0.5; # throttle between 0.0 and 1.0 of available thrust to apply
|
|
|
|
|
|
|
|
|
|
var curr_rotation_vel: Vector3 = Vector3();
|
|
|
|
@ -27,11 +27,11 @@ func _set_thruster_thrust(node: MeshInstance, power):
|
|
|
|
|
if node.name in __curr_shader_param_cache:
|
|
|
|
|
if __curr_shader_param_cache[node.name] == power:
|
|
|
|
|
#print("Skipped shader edit");
|
|
|
|
|
return;
|
|
|
|
|
pass;#return;
|
|
|
|
|
|
|
|
|
|
### DEBUG CODE
|
|
|
|
|
if node.name in __curr_shader_param_cache:
|
|
|
|
|
print("Editing "+node.name+" because "+str(__curr_shader_param_cache[node.name])+" != "+str(power)+" (old vs new)");
|
|
|
|
|
#if node.name in __curr_shader_param_cache:
|
|
|
|
|
#print("Editing "+node.name+" because "+str(__curr_shader_param_cache[node.name])+" != "+str(power)+" (old vs new)");
|
|
|
|
|
###
|
|
|
|
|
__curr_shader_param_cache[node.name] = power;
|
|
|
|
|
|
|
|
|
@ -120,7 +120,7 @@ func _physics_process(delta):
|
|
|
|
|
if timer <= 0.0:
|
|
|
|
|
set_main_engine_thrust(0.0);
|
|
|
|
|
set_X_rotational_thrust(0.0);
|
|
|
|
|
set_Y_rotational_thrust(0.0); # TODO fix issue with turning off rotational thrusters
|
|
|
|
|
set_Y_rotational_thrust(0.0);
|
|
|
|
|
|
|
|
|
|
timer = 1.0
|
|
|
|
|
else:
|
|
|
|
@ -129,14 +129,13 @@ func _physics_process(delta):
|
|
|
|
|
set_Y_rotational_thrust(lerp(0.0, 10.0, turn_instruction.y));
|
|
|
|
|
set_main_engine_thrust(lerp(0.0, 10.0, thrust_instruction));
|
|
|
|
|
self.transform = self.transform.orthonormalized();
|
|
|
|
|
|
|
|
|
|
### DEBUG CODE
|
|
|
|
|
print("Rotation: "+str(self.curr_rotation_vel)+", Velocity: "+str(self.curr_velocity)+" Remeining dV: "+str(self.curr_DV));
|
|
|
|
|
#print("Rotation: "+str(self.curr_rotation_vel)+", Velocity: "+str(self.curr_velocity)+" Remeining dV: "+str(self.curr_DV));
|
|
|
|
|
###
|
|
|
|
|
|
|
|
|
|
timer = 1.0;
|
|
|
|
|
|
|
|
|
|
self.curr_rotation_vel += turn_instruction * Vector3(MAX_TURN_RATE, MAX_TURN_RATE, 0.0) * delta;
|
|
|
|
|
self.curr_rotation_vel += turn_instruction * Vector3(MAX_TURN_RATE, MAX_TURN_RATE, MAX_TURN_RATE) * delta;
|
|
|
|
|
self.curr_thrust = thrust_instruction * ACCEL * delta;
|
|
|
|
|
self.curr_velocity += self.global_transform.basis.z * self.curr_thrust * -1;
|
|
|
|
|
self.curr_DV -= curr_thrust;
|
|
|
|
@ -149,6 +148,7 @@ func _physics_process(delta):
|
|
|
|
|
if self.curr_rotation_vel.length() > 0.0:
|
|
|
|
|
self.rotate_x(deg2rad(self.curr_rotation_vel.x));
|
|
|
|
|
self.rotate_y(deg2rad(self.curr_rotation_vel.y));
|
|
|
|
|
self.rotate_z(deg2rad(self.curr_rotation_vel.z));
|
|
|
|
|
if self.curr_velocity.length() > 0.0:
|
|
|
|
|
#self.translate(self.curr_velocity);
|
|
|
|
|
self.global_translate(self.curr_velocity);
|
|
|
|
|