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.
This commit is contained in:
Hugo Locurcio
2025-10-02 09:14:08 +02:00
committed by GitHub
parent 711822a319
commit 57daa67c23
9 changed files with 28 additions and 5 deletions

View File

@@ -129,7 +129,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
curve = SubResource("5")
[node name="SpawnLocation" type="PathFollow3D" parent="SpawnPath"]
transform = Transform3D(-4.37113e-08, 0, 0.999999, 0, 1, 0, -0.999999, 0, -4.37113e-08, 14, 0, -15)
transform = Transform3D(-4.3711346e-08, 0, 0.999999, 0, 1, 0, -0.999999, 0, -4.3711346e-08, 14, 0, -15)
rotation_mode = 1
cubic_interp = false
loop = false

View File

@@ -14,7 +14,13 @@ func _physics_process(_delta):
func initialize(start_position, player_position):
look_at_from_position(start_position, player_position, Vector3.UP)
# Ignore the player's height, so that the mob's orientation is not slightly
# shifted if the mob spawns while the player is jumping.
var target = Vector3(player_position.x, start_position.y, player_position.z)
look_at_from_position(start_position, target, Vector3.UP)
# Rotate this mob randomly within range of -45 and +45 degrees,
# so that it doesn't move directly towards the player.
rotate_y(randf_range(-PI / 4, PI / 4))
var random_speed = randf_range(min_speed, max_speed)

View File

@@ -80,7 +80,7 @@ aabb = AABB(-1.19986, 0.251327, -1.57098, 2.41047, 1.09305, 3.17223)
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
callback_mode_process = 0
libraries = {
"": SubResource("AnimationLibrary_5n6vs")
&"": SubResource("AnimationLibrary_5n6vs")
}
autoplay = "float"

View File

@@ -88,7 +88,7 @@ shape = SubResource("CylinderShape3D_76fa1")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
callback_mode_process = 0
libraries = {
"": SubResource("AnimationLibrary_aq6tr")
&"": SubResource("AnimationLibrary_aq6tr")
}
autoplay = "float"

View File

@@ -15,9 +15,11 @@ dest_files=["res://.godot/imported/mob.glb-3afb43c03b9d1598b6af5154e2543eac.scn"
nodes/root_type="Spatial"
nodes/root_name="Scene Root"
nodes/root_script=null
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=false
@@ -32,6 +34,9 @@ animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=0
gltf/embedded_image_handling=1

View File

@@ -15,9 +15,11 @@ dest_files=["res://.godot/imported/player.glb-08dcfb373480a049995065542e37637b.s
nodes/root_type="Spatial"
nodes/root_name="Scene Root"
nodes/root_script=null
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=false
@@ -32,6 +34,9 @@ animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=0
gltf/embedded_image_handling=1

View File

@@ -21,6 +21,7 @@ msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
modulate_color_glyphs=false
hinting=1
subpixel_positioning=1
keep_rounding_remainders=true

View File

@@ -18,6 +18,8 @@ dest_files=["res://.godot/imported/icon.webp-e94f9a68b0f625a567a797079e4d325f.ct
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
@@ -25,6 +27,10 @@ mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false

View File

@@ -17,7 +17,7 @@ This is a finished version of the game featured in the \"Your first 3D game\"
tutorial in the official documentation."
config/tags=PackedStringArray("3d", "demo", "official")
run/main_scene="res://Main.tscn"
config/features=PackedStringArray("4.4")
config/features=PackedStringArray("4.5")
config/icon="res://icon.webp"
[autoload]