Skip to content

Commit 33494c4

Browse files
committed
[3DP] Update to Godot 3.1.2
Conform to style guide, add WASD movement, add controller support
1 parent 76d43cf commit 33494c4

File tree

15 files changed

+937
-2222
lines changed

15 files changed

+937
-2222
lines changed

3d/platformer/bullet.gd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
21
extends RigidBody
32

4-
# Member variables
5-
var disabled = false
3+
#warning-ignore:unused_class_variable
4+
var enabled = true

3d/platformer/bullet.tscn

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ surfaces/0 = {
2525
"vertex_count": 34
2626
}
2727

28-
[sub_resource type="SpatialMaterial" id=6]
28+
[sub_resource type="SpatialMaterial" id=3]
2929
albedo_color = Color( 0.7, 0.7, 0.7, 1 )
3030
metallic = 0.1
3131
roughness = 0.0
@@ -35,8 +35,7 @@ emission_energy = 3.71
3535
emission_operator = 0
3636
emission_on_uv2 = false
3737

38-
[sub_resource type="Animation" id=3]
39-
resource_name = "life"
38+
[sub_resource type="Animation" id=4]
4039
length = 2.0
4140
tracks/0/type = "value"
4241
tracks/0/path = NodePath("Sphere:visible")
@@ -63,7 +62,7 @@ tracks/1/keys = {
6362
"values": [ true, false ]
6463
}
6564
tracks/2/type = "method"
66-
tracks/2/path = NodePath(".:")
65+
tracks/2/path = NodePath(".")
6766
tracks/2/interp = 1
6867
tracks/2/loop_wrap = true
6968
tracks/2/imported = false
@@ -77,19 +76,19 @@ tracks/2/keys = {
7776
} ]
7877
}
7978

80-
[sub_resource type="Gradient" id=8]
79+
[sub_resource type="Gradient" id=5]
8180
colors = PoolColorArray( 1, 1, 1, 1, 1, 1, 1, 0 )
8281

83-
[sub_resource type="GradientTexture" id=9]
84-
gradient = SubResource( 8 )
82+
[sub_resource type="GradientTexture" id=6]
83+
gradient = SubResource( 5 )
8584

8685
[sub_resource type="ParticlesMaterial" id=7]
8786
spread = 0.0
8887
gravity = Vector3( 0, 0, 0 )
8988
scale = 0.3
90-
color_ramp = SubResource( 9 )
89+
color_ramp = SubResource( 6 )
9190

92-
[sub_resource type="SphereShape" id=5]
91+
[sub_resource type="SphereShape" id=8]
9392
radius = 0.27
9493

9594
[node name="Bullet" type="RigidBody"]
@@ -102,13 +101,11 @@ __meta__ = {
102101
[node name="Sphere" type="MeshInstance" parent="."]
103102
transform = Transform( 0.24972, 0, 0, 0, 0.24972, 0, 0, 0, 0.24972, 0.00159812, 0.0110106, 0.0045104 )
104103
mesh = SubResource( 2 )
105-
skeleton = NodePath("..:")
106-
material/0 = SubResource( 6 )
104+
material/0 = SubResource( 3 )
107105

108106
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
109-
root_node = NodePath("..:")
110107
autoplay = "life"
111-
anims/life = SubResource( 3 )
108+
anims/life = SubResource( 4 )
112109

113110
[node name="Particles" type="Particles" parent="."]
114111
amount = 16
@@ -120,4 +117,4 @@ process_material = SubResource( 7 )
120117
draw_pass_1 = SubResource( 2 )
121118

122119
[node name="CollisionShape" type="CollisionShape" parent="."]
123-
shape = SubResource( 5 )
120+
shape = SubResource( 8 )

3d/platformer/coin.gd

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
21
extends Area
32

4-
# Member variables
53
var taken = false
64

7-
85
func _on_coin_body_enter(body):
96
if not taken and body is preload("res://player.gd"):
107
get_node("Animation").play("take")

3d/platformer/coin.tscn

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,24 @@ tracks/2/keys = {
8585
"values": [ true ]
8686
}
8787

88-
[sub_resource type="SphereShape" id=7]
88+
[sub_resource type="SphereShape" id=5]
8989
radius = 0.312546
9090

91-
[sub_resource type="Gradient" id=8]
91+
[sub_resource type="Gradient" id=6]
9292
colors = PoolColorArray( 1, 1, 1, 1, 1, 1, 1, 0 )
9393

94-
[sub_resource type="GradientTexture" id=9]
95-
gradient = SubResource( 8 )
94+
[sub_resource type="GradientTexture" id=7]
95+
gradient = SubResource( 6 )
9696

97-
[sub_resource type="ParticlesMaterial" id=10]
97+
[sub_resource type="ParticlesMaterial" id=8]
9898
emission_shape = 2
9999
emission_box_extents = Vector3( 0.3, 0.3, 0.3 )
100100
initial_velocity = 5.51
101+
angular_velocity = 4.27461e-05
101102
scale = 0.1
102-
color_ramp = SubResource( 9 )
103+
color_ramp = SubResource( 7 )
103104

104-
[sub_resource type="SpatialMaterial" id=11]
105+
[sub_resource type="SpatialMaterial" id=9]
105106
flags_transparent = true
106107
flags_unshaded = true
107108
vertex_color_use_as_albedo = true
@@ -114,8 +115,8 @@ particles_anim_loop = false
114115
albedo_color = Color( 1, 1, 0.759137, 1 )
115116
albedo_texture = ExtResource( 3 )
116117

117-
[sub_resource type="QuadMesh" id=12]
118-
material = SubResource( 11 )
118+
[sub_resource type="QuadMesh" id=10]
119+
material = SubResource( 9 )
119120

120121
[node name="Coin" type="Area"]
121122
input_ray_pickable = false
@@ -128,18 +129,16 @@ __meta__ = {
128129
transform = Transform( 0.2, 0, 0, 0, -3.25841e-08, 0.2, 0, -0.2, -3.25841e-08, 0.00550658, 0.532125, 0.000651598 )
129130
layers = 2
130131
mesh = SubResource( 2 )
131-
skeleton = NodePath("..:")
132132
material/0 = null
133133

134134
[node name="Animation" type="AnimationPlayer" parent="."]
135-
root_node = NodePath("..:")
136135
autoplay = "spin"
137136
anims/spin = SubResource( 3 )
138137
anims/take = SubResource( 4 )
139138

140139
[node name="CollisionShape" type="CollisionShape" parent="."]
141140
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00894194, 0.575859, 0.0193955 )
142-
shape = SubResource( 7 )
141+
shape = SubResource( 5 )
143142

144143
[node name="VisibilityEnabler" type="VisibilityEnabler" parent="."]
145144
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0321827, 0.57887, 0.0268312 )
@@ -155,6 +154,6 @@ emitting = false
155154
one_shot = true
156155
explosiveness = 1.0
157156
visibility_aabb = AABB( -4.12919, -4, -4, 8.25837, 8, 8 )
158-
process_material = SubResource( 10 )
159-
draw_pass_1 = SubResource( 12 )
157+
process_material = SubResource( 8 )
158+
draw_pass_1 = SubResource( 10 )
160159
[connection signal="body_entered" from="." to="." method="_on_coin_body_enter"]

3d/platformer/enemy.gd

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
21
extends RigidBody
32

4-
# Member variables
53
const STATE_WALKING = 0
64
const STATE_DYING = 1
75

@@ -14,15 +12,17 @@ var rot_speed = 1
1412

1513
var dying = false
1614

15+
onready var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
1716

1817
func _integrate_forces(state):
1918
var delta = state.get_step()
2019
var lv = state.get_linear_velocity()
2120
var g = state.get_total_gravity()
22-
# get_total_gravity returns zero for the first few frames, leading to errors
23-
if g == Vector3.ZERO: g = Vector3 (0, -9.8, 0)
21+
# get_total_gravity returns zero for the first few frames, leading to errors.
22+
if g == Vector3.ZERO:
23+
g = gravity
2424

25-
lv += g * delta # Apply gravity
25+
lv += g * delta # Apply gravity.
2626
var up = -g.normalized()
2727

2828
if dying:
@@ -34,22 +34,20 @@ func _integrate_forces(state):
3434
var dp = state.get_contact_local_normal(i)
3535

3636
if cc:
37-
if cc is preload("res://bullet.gd") and not cc.disabled:
37+
if cc is preload("res://bullet.gd") and cc.enabled:
3838
set_mode(MODE_RIGID)
3939
dying = true
40-
#lv = s.get_contact_local_normal(i)*400
4140
state.set_angular_velocity(-dp.cross(up).normalized() * 33.0)
4241
get_node("AnimationPlayer").play("impact")
4342
get_node("AnimationPlayer").queue("explode")
44-
set_friction(1)
45-
cc.disabled = true
46-
get_node("sound_hit").play()
43+
cc.enabled = false
44+
get_node("SoundHit").play()
4745
return
4846

49-
var col_floor = get_node("Armature/ray_floor").is_colliding()
50-
var col_wall = get_node("Armature/ray_wall").is_colliding()
47+
var col_floor = get_node("Armature/RayFloor").is_colliding()
48+
var col_wall = get_node("Armature/RayWall").is_colliding()
5149

52-
var advance = not col_wall and col_floor
50+
var advance = col_floor and not col_wall
5351

5452
var dir = get_node("Armature").get_transform().basis[2].normalized()
5553
var deaccel_dir = dir
@@ -60,7 +58,7 @@ func _integrate_forces(state):
6058
deaccel_dir = dir.cross(g).normalized()
6159
else:
6260
if prev_advance:
63-
rot_dir = 1 # randf()*2.0 - 1.0
61+
rot_dir = 1
6462

6563
dir = Basis(up, rot_dir * rot_speed * delta).xform(dir)
6664
get_node("Armature").set_transform(Transform().looking_at(-dir, up))

0 commit comments

Comments
 (0)