Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix look_at_from_position() usage in Squash the Creeps (3D) #1165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Feb 10, 2025

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.

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.
@Calinou Calinou force-pushed the squash-the-creeps-fix-look-at-from-position branch from 89ba3f6 to f08df2b Compare February 10, 2025 12:10
@gabriele2000
Copy link

gabriele2000 commented Mar 2, 2025

In my modest opinion, as a user and someone with a very small (for now) background on programming, I'd like to propose a change.

The following changed code

func initialize(start_position, player_position):
	# 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)

could be just

func initialize(start_position, player_position):
	# Ignore the player's height, so that the mob's orientation is not slightly
	# shifted if the mob spawns while the player is jumping.
        # start_position.y could also be written as 0.0
	player_position = Vector3(player_position.x, start_position.y, player_position.z)
	look_at_from_position(start_position, player_position, Vector3.UP)

player_position has been already declared inside func, now we just need to overwrite the player_position.y value then process the overwrited value.
No need to declare a variable, let alone a new one, just for a small correction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants