Skip to content

Commit 57daa67

Browse files
authored
Fix look_at_from_position() usage in Squash the Creeps (3D) (#1165)
The mob's orientation was previously shifted according to the player's height, which could lead to collision and movement issues that were difficult to diagnose.
1 parent 711822a commit 57daa67

File tree

9 files changed

+28
-5
lines changed

9 files changed

+28
-5
lines changed

3d/squash_the_creeps/Main.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
129129
curve = SubResource("5")
130130

131131
[node name="SpawnLocation" type="PathFollow3D" parent="SpawnPath"]
132-
transform = Transform3D(-4.37113e-08, 0, 0.999999, 0, 1, 0, -0.999999, 0, -4.37113e-08, 14, 0, -15)
132+
transform = Transform3D(-4.3711346e-08, 0, 0.999999, 0, 1, 0, -0.999999, 0, -4.3711346e-08, 14, 0, -15)
133133
rotation_mode = 1
134134
cubic_interp = false
135135
loop = false

3d/squash_the_creeps/Mob.gd

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ func _physics_process(_delta):
1414

1515

1616
func initialize(start_position, player_position):
17-
look_at_from_position(start_position, player_position, Vector3.UP)
17+
# Ignore the player's height, so that the mob's orientation is not slightly
18+
# shifted if the mob spawns while the player is jumping.
19+
var target = Vector3(player_position.x, start_position.y, player_position.z)
20+
look_at_from_position(start_position, target, Vector3.UP)
21+
22+
# Rotate this mob randomly within range of -45 and +45 degrees,
23+
# so that it doesn't move directly towards the player.
1824
rotate_y(randf_range(-PI / 4, PI / 4))
1925

2026
var random_speed = randf_range(min_speed, max_speed)

3d/squash_the_creeps/Mob.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ aabb = AABB(-1.19986, 0.251327, -1.57098, 2.41047, 1.09305, 3.17223)
8080
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
8181
callback_mode_process = 0
8282
libraries = {
83-
"": SubResource("AnimationLibrary_5n6vs")
83+
&"": SubResource("AnimationLibrary_5n6vs")
8484
}
8585
autoplay = "float"
8686

3d/squash_the_creeps/Player.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ shape = SubResource("CylinderShape3D_76fa1")
8888
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
8989
callback_mode_process = 0
9090
libraries = {
91-
"": SubResource("AnimationLibrary_aq6tr")
91+
&"": SubResource("AnimationLibrary_aq6tr")
9292
}
9393
autoplay = "float"
9494

3d/squash_the_creeps/art/mob.glb.import

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ dest_files=["res://.godot/imported/mob.glb-3afb43c03b9d1598b6af5154e2543eac.scn"
1515

1616
nodes/root_type="Spatial"
1717
nodes/root_name="Scene Root"
18+
nodes/root_script=null
1819
nodes/apply_root_scale=true
1920
nodes/root_scale=1.0
2021
nodes/import_as_skeleton_bones=false
22+
nodes/use_name_suffixes=true
2123
nodes/use_node_type_suffixes=true
2224
meshes/ensure_tangents=true
2325
meshes/generate_lods=false
@@ -32,6 +34,9 @@ animation/trimming=false
3234
animation/remove_immutable_tracks=true
3335
animation/import_rest_as_RESET=false
3436
import_script/path=""
37+
materials/extract=0
38+
materials/extract_format=0
39+
materials/extract_path=""
3540
_subresources={}
3641
gltf/naming_version=0
3742
gltf/embedded_image_handling=1

3d/squash_the_creeps/art/player.glb.import

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ dest_files=["res://.godot/imported/player.glb-08dcfb373480a049995065542e37637b.s
1515

1616
nodes/root_type="Spatial"
1717
nodes/root_name="Scene Root"
18+
nodes/root_script=null
1819
nodes/apply_root_scale=true
1920
nodes/root_scale=1.0
2021
nodes/import_as_skeleton_bones=false
22+
nodes/use_name_suffixes=true
2123
nodes/use_node_type_suffixes=true
2224
meshes/ensure_tangents=true
2325
meshes/generate_lods=false
@@ -32,6 +34,9 @@ animation/trimming=false
3234
animation/remove_immutable_tracks=true
3335
animation/import_rest_as_RESET=false
3436
import_script/path=""
37+
materials/extract=0
38+
materials/extract_format=0
39+
materials/extract_path=""
3540
_subresources={}
3641
gltf/naming_version=0
3742
gltf/embedded_image_handling=1

3d/squash_the_creeps/fonts/Montserrat-Medium.ttf.import

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ msdf_pixel_range=8
2121
msdf_size=48
2222
allow_system_fallback=true
2323
force_autohinter=false
24+
modulate_color_glyphs=false
2425
hinting=1
2526
subpixel_positioning=1
2627
keep_rounding_remainders=true

3d/squash_the_creeps/icon.webp.import

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@ dest_files=["res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ct
1818
compress/mode=0
1919
compress/high_quality=false
2020
compress/lossy_quality=0.7
21+
compress/uastc_level=0
22+
compress/rdo_quality_loss=0.0
2123
compress/hdr_compression=1
2224
compress/normal_map=0
2325
compress/channel_pack=0
2426
mipmaps/generate=false
2527
mipmaps/limit=-1
2628
roughness/mode=0
2729
roughness/src_normal=""
30+
process/channel_remap/red=0
31+
process/channel_remap/green=1
32+
process/channel_remap/blue=2
33+
process/channel_remap/alpha=3
2834
process/fix_alpha_border=true
2935
process/premult_alpha=false
3036
process/normal_map_invert_y=false

3d/squash_the_creeps/project.godot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This is a finished version of the game featured in the \"Your first 3D game\"
1717
tutorial in the official documentation."
1818
config/tags=PackedStringArray("3d", "demo", "official")
1919
run/main_scene="res://Main.tscn"
20-
config/features=PackedStringArray("4.4")
20+
config/features=PackedStringArray("4.5")
2121
config/icon="res://icon.webp"
2222

2323
[autoload]

0 commit comments

Comments
 (0)