-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from GREEN-CHAOS/main
adds Parachute and enhances Camera Nice next tiny update
- Loading branch information
Showing
10 changed files
with
251 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
[gd_scene load_steps=7 format=2] | ||
|
||
[ext_resource path="res://scripts/RocketParts/Parachute/Parachute.gd" type="Script" id=1] | ||
|
||
[sub_resource type="CylinderMesh" id=1] | ||
|
||
[sub_resource type="CylinderMesh" id=2] | ||
|
||
[sub_resource type="CylinderMesh" id=3] | ||
|
||
[sub_resource type="Animation" id=4] | ||
resource_name = "parachute_cut" | ||
|
||
[sub_resource type="Animation" id=5] | ||
length = 3.0 | ||
tracks/0/type = "transform" | ||
tracks/0/path = NodePath("Parachute") | ||
tracks/0/interp = 1 | ||
tracks/0/loop_wrap = true | ||
tracks/0/imported = false | ||
tracks/0/enabled = true | ||
tracks/0/keys = PoolRealArray( ) | ||
tracks/1/type = "bezier" | ||
tracks/1/path = NodePath("Parachute:translation:x") | ||
tracks/1/interp = 1 | ||
tracks/1/loop_wrap = true | ||
tracks/1/imported = false | ||
tracks/1/enabled = true | ||
tracks/1/keys = { | ||
"points": PoolRealArray( 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0 ), | ||
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 3 ) | ||
} | ||
tracks/2/type = "bezier" | ||
tracks/2/path = NodePath("Parachute:translation:y") | ||
tracks/2/interp = 1 | ||
tracks/2/loop_wrap = true | ||
tracks/2/imported = false | ||
tracks/2/enabled = true | ||
tracks/2/keys = { | ||
"points": PoolRealArray( 0, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 2, -0.25, 0, 0.25, 0, 2.3, -0.25, 0, 0.25, 0, 15.4056, -0.25, 0, 0.25, 0 ), | ||
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 3 ) | ||
} | ||
tracks/3/type = "bezier" | ||
tracks/3/path = NodePath("Parachute:translation:z") | ||
tracks/3/interp = 1 | ||
tracks/3/loop_wrap = true | ||
tracks/3/imported = false | ||
tracks/3/enabled = true | ||
tracks/3/keys = { | ||
"points": PoolRealArray( 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0 ), | ||
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 3 ) | ||
} | ||
tracks/4/type = "bezier" | ||
tracks/4/path = NodePath("Parachute:scale:x") | ||
tracks/4/interp = 1 | ||
tracks/4/loop_wrap = true | ||
tracks/4/imported = false | ||
tracks/4/enabled = true | ||
tracks/4/keys = { | ||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1.5, -0.25, 0, 0.25, 0, 20, -0.25, 0, 0.25, 0 ), | ||
"times": PoolRealArray( 0, 0.1, 0.3, 3 ) | ||
} | ||
tracks/5/type = "bezier" | ||
tracks/5/path = NodePath("Parachute:scale:y") | ||
tracks/5/interp = 1 | ||
tracks/5/loop_wrap = true | ||
tracks/5/imported = false | ||
tracks/5/enabled = true | ||
tracks/5/keys = { | ||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0 ), | ||
"times": PoolRealArray( 0, 0.1, 0.3, 3 ) | ||
} | ||
tracks/6/type = "bezier" | ||
tracks/6/path = NodePath("Parachute:scale:z") | ||
tracks/6/interp = 1 | ||
tracks/6/loop_wrap = true | ||
tracks/6/imported = false | ||
tracks/6/enabled = true | ||
tracks/6/keys = { | ||
"points": PoolRealArray( 1, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1.5, -0.25, 0, 0.25, 0, 20, -0.25, 0, 0.25, 0 ), | ||
"times": PoolRealArray( 0, 0.1, 0.3, 3 ) | ||
} | ||
|
||
[node name="Parachute" type="RigidBody"] | ||
script = ExtResource( 1 ) | ||
housing = NodePath("House") | ||
parachute = NodePath("Parachute") | ||
cap = NodePath("Cap") | ||
parachute_animation = NodePath("AnimationPlayer") | ||
offset = NodePath("House") | ||
|
||
[node name="House" type="MeshInstance" parent="."] | ||
transform = Transform( 2, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0 ) | ||
mesh = SubResource( 1 ) | ||
skeleton = NodePath("") | ||
material/0 = null | ||
|
||
[node name="Cap" type="MeshInstance" parent="."] | ||
transform = Transform( 1, 0, 0, 0, 0.2, 0, 0, 0, 1, 0, 1.14392, 0 ) | ||
mesh = SubResource( 2 ) | ||
material/0 = null | ||
|
||
[node name="Parachute" type="MeshInstance" parent="."] | ||
transform = Transform( 20, 0, 0, 0, 1, 0, 0, 0, 20, 0, 15.4056, 0 ) | ||
mesh = SubResource( 3 ) | ||
material/0 = null | ||
|
||
[node name="Joint" type="Generic6DOFJoint" parent="."] | ||
|
||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] | ||
anims/parachute_cut = SubResource( 4 ) | ||
anims/parachute_open = SubResource( 5 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
class_name Parachute | ||
extends Part | ||
|
||
enum ParachuteState { READY, DEPLOYED = 2, EXPLOYED = 3, } | ||
export(NodePath) var housing | ||
export(NodePath) var parachute | ||
export(NodePath) var cap | ||
export(NodePath) var parachute_animation | ||
export(NodePath) var offset | ||
export var air_thickness = 3 | ||
var parachute_state | ||
var density = 1.23 | ||
var drag_coefficient = 0.5 | ||
var parachute_area = 1 | ||
var force_length = 1 | ||
var cw = 2.1 | ||
|
||
|
||
func parachute_open(): | ||
if parachute_state == ParachuteState.READY: | ||
parachute.visible = true | ||
housing.visible = false | ||
cap.visible = false | ||
parachute_animation.play("parachute_open") | ||
parachute_state = ParachuteState.DEPLOYED | ||
parachute_area = parachute.scale.x * parachute.scale.z * PI | ||
else: print("Parachute not available") | ||
|
||
func parachute_cut(): | ||
if parachute_state == ParachuteState.DEPLOYED: | ||
parachute_state = ParachuteState.EXPLOYED | ||
else: print("Parachute Cut is not available") | ||
|
||
func parachute_load(): | ||
if parachute_state == ParachuteState.EXPLOYED: | ||
parachute_state = ParachuteState.DEPLOYED | ||
else: print("No parachute to load") | ||
|
||
func _ready(): | ||
housing = get_node(housing) | ||
parachute = get_node(parachute) | ||
cap = get_node(cap) | ||
parachute_animation = get_node(parachute_animation) | ||
offset = get_node(offset) | ||
parachute.visible = false | ||
parachute_state = ParachuteState.READY | ||
|
||
func _integrate_forces(state): | ||
_integrate_parachute_forces(state) | ||
|
||
func _integrate_parachute_forces(state): | ||
if parachute_state == ParachuteState.DEPLOYED: | ||
var v = linear_velocity.length() | ||
var forceMagnitude = 0.5 * drag_coefficient * parachute_area * v * v | ||
var forceDirection = -linear_velocity.normalized() | ||
var forceAppliedLocation = offset.translation | ||
add_force(forceMagnitude * forceDirection, forceAppliedLocation) | ||
|
Oops, something went wrong.