-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFlying Gun.tscn
245 lines (183 loc) · 6.79 KB
/
Flying Gun.tscn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
[gd_scene load_steps=19 format=2]
[ext_resource path="res://object scenes/Gun.tscn" type="PackedScene" id=1]
[ext_resource path="res://highlight_material.tres" type="Material" id=2]
[ext_resource path="res://glow_material.tres" type="Material" id=3]
[ext_resource path="res://Sprites/circle_05_transparent.png" type="Texture" id=4]
[sub_resource type="PhysicsMaterial" id=1]
friction = 0.28
[sub_resource type="GDScript" id=2]
script/source = "extends RigidBody
export(float, 0, 500) var recall_accel
export(float, 0, 500) var recall_max_speed
export(float, -20, 20) var spin_speed
export(float, 0, 500) var side_movement_force
export(float, 0, 2) var side_movement_time = 1
var sideMovementTime = 1
var sideMovementElapsed = 0
var sideMovementRight = false
var player;
var recalling = false
var originalGravityScale = gravity_scale
var pickupArea : Area
func _ready():
pickupArea = get_node(\"Pickup Area\")
pickupArea.monitoring = false
start()
func start():
yield(delay(0.05), \"timeout\")
apply_torque_impulse(get_transform().basis.x * spin_speed)
yield(delay(0.5), \"timeout\")
pickupArea.monitoring = true
func glow():
get_node(\"Glow Through Wall\").visible = false;
get_node(\"Highlighted Gun\").visible = true
get_node(\"Gun\").visible = false
func unglow():
get_node(\"Glow Through Wall\").visible = true;
get_node(\"Highlighted Gun\").visible = false
get_node(\"Gun\").visible = true
func recall(left):
recalling = true
gravity_scale = 0
sideMovementRight = !left
sideMovementElapsed = 0
func cantRecall():
recalling = false
gravity_scale = originalGravityScale
func _process(delta):
if not player:
player = get_node(\"/root/Game\").find_node(\"Player\", true, false)
if (recalling):
sideMovementElapsed += delta
func _physics_process(delta):
if (recalling):
if (sideMovementElapsed < sideMovementTime):
var dir = player.pitch.global_transform.basis.x if sideMovementRight else -player.pitch.global_transform.basis.x
add_central_force(side_movement_force * dir)
func _integrate_forces(state):
if (player && recalling):
var toPlayer = player.camera.global_transform.origin - global_transform.origin
state.add_central_force(toPlayer * recall_accel)
if (state.linear_velocity.length_squared() > recall_max_speed * recall_max_speed):
state.linear_velocity = state.linear_velocity.normalized() * recall_max_speed;
func delay(seconds : float = 1, start : bool = true):
var timer = Timer.new()
add_child(timer)
timer.one_shot = true
timer.wait_time = seconds
if start:
timer.start()
return timer
"
[sub_resource type="SpatialMaterial" id=3]
render_priority = 1
flags_transparent = true
flags_unshaded = true
flags_vertex_lighting = true
flags_no_depth_test = true
flags_do_not_receive_shadows = true
flags_disable_ambient_light = true
albedo_color = Color( 1, 0.956863, 0, 0.278431 )
[sub_resource type="CapsuleShape" id=4]
radius = 0.1571
height = 0.383166
[sub_resource type="CapsuleShape" id=5]
radius = 0.103633
height = 0.678108
[sub_resource type="Gradient" id=6]
offsets = PoolRealArray( 0, 0.856397, 1 )
colors = PoolColorArray( 1, 0, 0, 1, 0.0339426, 0, 0, 1, 0, 0, 0, 1 )
[sub_resource type="GradientTexture" id=7]
gradient = SubResource( 6 )
[sub_resource type="Curve" id=8]
_data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), -3.64284, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=9]
curve = SubResource( 8 )
[sub_resource type="ParticlesMaterial" id=10]
spread = 0.0
gravity = Vector3( 0, 0, 0 )
angular_velocity = 4.48416e-43
scale_curve = SubResource( 9 )
color_ramp = SubResource( 7 )
[sub_resource type="SpatialMaterial" id=11]
flags_transparent = true
flags_unshaded = true
flags_do_not_receive_shadows = true
flags_disable_ambient_light = true
vertex_color_use_as_albedo = true
params_blend_mode = 1
params_depth_draw_mode = 3
params_line_width = 0.1
params_billboard_mode = 3
particles_anim_h_frames = 1
particles_anim_v_frames = 1
particles_anim_loop = false
albedo_texture = ExtResource( 4 )
[sub_resource type="QuadMesh" id=12]
material = SubResource( 11 )
size = Vector2( 0.3, 0.3 )
[sub_resource type="SphereShape" id=13]
radius = 1.4215
[sub_resource type="SphereShape" id=14]
radius = 1.42896
[node name="Flying Gun" type="RigidBody"]
mass = 10.0
physics_material_override = SubResource( 1 )
gravity_scale = 0.1
continuous_cd = true
contacts_reported = 3
contact_monitor = true
script = SubResource( 2 )
recall_accel = 140.0
recall_max_speed = 14.0
spin_speed = -8.0
side_movement_force = 500.0
side_movement_time = 0.4
[node name="Gun" parent="." instance=ExtResource( 1 )]
editor/display_folded = true
transform = Transform( -0.75, 0, 6.55671e-08, 0, 0.75, 0, -6.55671e-08, 0, -0.75, 0, 0, 0 )
[node name="Highlighted Gun" parent="." instance=ExtResource( 1 )]
transform = Transform( -0.75, 0, 6.55671e-08, 0, 0.75, 0, -6.55671e-08, 0, -0.75, 0, 0, 0 )
[node name="MeshInstance" parent="Highlighted Gun" index="0"]
material/0 = ExtResource( 2 )
[node name="Glow" parent="Highlighted Gun" instance=ExtResource( 1 )]
transform = Transform( 1.3573, 0, -2.13163e-14, 0, 1.3573, 0, 2.13163e-14, 0, 1.3573, 7.32497e-08, -0.139806, -0.0711843 )
[node name="MeshInstance" parent="Highlighted Gun/Glow" index="0"]
material/0 = ExtResource( 3 )
[node name="Glow Through Wall" parent="." instance=ExtResource( 1 )]
transform = Transform( -0.75, 0, 1.13247e-07, 0, 0.75, 0, -1.13247e-07, 0, -0.75, 0, 0, 0 )
[node name="MeshInstance" parent="Glow Through Wall" index="0"]
transform = Transform( 0.196, 0, 0, 0, 0.196, 0, 0, 0, 0.196, 0, 0, 0 )
material/0 = SubResource( 3 )
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.0990103, -0.208082 )
shape = SubResource( 4 )
[node name="CollisionShape2" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.310561, 0.0495731 )
shape = SubResource( 5 )
[node name="Particles" type="Particles" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.17147, -0.198528 )
amount = 3000
lifetime = 5.0
visibility_aabb = AABB( -4.00635, -4, -3.70996, 8, 8, 8 )
local_coords = false
draw_order = 2
process_material = SubResource( 10 )
draw_pass_1 = SubResource( 12 )
[node name="Gun Target Area" type="Area" parent="."]
input_ray_pickable = true
collision_layer = 2
collision_mask = 2
[node name="CollisionShape" type="CollisionShape" parent="Gun Target Area"]
transform = Transform( 1.2, 0, 0, 0, 1.2, 0, 0, 0, 1.2, 0, 0, 0 )
shape = SubResource( 13 )
[node name="Pickup Area" type="Area" parent="."]
monitoring = false
collision_layer = 4
collision_mask = 4
[node name="CollisionShape" type="CollisionShape" parent="Pickup Area"]
transform = Transform( 1.2, 0, 0, 0, 1.2, 0, 0, 0, 1.2, 0, 0, 0 )
shape = SubResource( 14 )
[editable path="Highlighted Gun"]
[editable path="Highlighted Gun/Glow"]
[editable path="Glow Through Wall"]