sprite merge

This commit is contained in:
Alexey 2025-07-18 16:22:02 +03:00
commit bb914ca82c

View file

@ -8,10 +8,11 @@ func _process(delta: float) -> void:
var camera = get_viewport().get_camera_3d()
if Engine.is_editor_hint():
camera = EditorInterface.get_editor_viewport_3d().get_camera_3d()
var rotation_to_camera = -vec3_to_vec2(global_transform.basis.z).angle_to(vec3_to_vec2(camera.global_position)) + PI
# Angle between camera's -basis.z (forward direction) and direction to camera
var angle = vec3_to_vec2(-global_transform.basis.z).angle_to(vec3_to_vec2(global_position - camera.global_position)) + PI
var chosen_index = 0
for i in rotations.keys():
if abs(rotation_to_camera-i) < abs(rotation_to_camera-chosen_index):
if abs(angle-i) < abs(angle-chosen_index):
chosen_index = i
texture = rotations[chosen_index]
@ -24,4 +25,4 @@ func entry_generator():
rotations[TAU/rotation_count*i] = Texture2D.new()
func vec3_to_vec2(vector : Vector3) -> Vector2:
return Vector2(vector.x,vector.z).normalized()
return Vector2(vector.z,vector.x).normalized()