Skip to content

Instantly share code, notes, and snippets.

View Hangman's full-sized avatar
🏠
Working from home

Hangman

🏠
Working from home
View GitHub Profile
@Hangman
Hangman / LookAt.gd
Last active November 17, 2023 05:57
Godot look_at fix (avoid getting the aligned error)
# Written for Godot 4.2.x
class_name LookAt
static func safe_look_at(node: Node3D, target: Vector3) -> void:
var direction: Vector3 = (target - node.global_transform.origin).normalized()
for up in [Vector3.UP, Vector3.RIGHT, Vector3.BACK]:
if abs(up.dot(direction)) != 1:
node.look_at(target, up)
break