add radio

This commit is contained in:
2026-04-13 23:05:52 +02:00
parent adaa9eda98
commit dc0bf0ba37
10 changed files with 158 additions and 6 deletions

View File

@@ -16,6 +16,7 @@ var total_yaw: float = 0.0
var total_pitch: float = 0.0
var orbit_distance: float = 0.0
var current_pan: Vector2 = Vector2.ZERO
var is_active: bool = false
func _ready() -> void:
total_yaw = global_rotation.y
@@ -26,12 +27,14 @@ func _ready() -> void:
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_photo_mode"):
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
is_active = !is_active
if !is_active:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
if event is InputEventMouseMotion and is_active:
total_yaw -= event.relative.x * rotation_speed
if event.is_action_pressed("take_photo"):
@@ -40,29 +43,33 @@ func _unhandled_input(event: InputEvent) -> void:
func _process(delta: float) -> void:
if not rotation_target:
return
var pan_input = Input.get_vector("photo_pan_left", "photo_pan_right", "photo_pan_up", "photo_pan_down")
var rot_basis = Basis.from_euler(Vector3(total_pitch, total_yaw, 0))
if pan_input != Vector2.ZERO:
if pan_input != Vector2.ZERO and is_active:
current_pan.x += pan_input.x * pan_speed * delta
current_pan.y += -pan_input.y * pan_speed * delta
if movement_bounds.size != Vector3.ZERO:
current_pan.x = clampf(current_pan.x, movement_bounds.position.x, movement_bounds.position.x + movement_bounds.size.x)
current_pan.y = clampf(current_pan.y, movement_bounds.position.y, movement_bounds.position.y + movement_bounds.size.y)
var right_dir = rot_basis.x.normalized()
var up_dir = rot_basis.y.normalized()
var final_pan_offset = (right_dir * current_pan.x) + (up_dir * current_pan.y)
var orbit_pos = rotation_target.global_position + (rot_basis * Vector3(0, 0, orbit_distance))
global_position = orbit_pos + final_pan_offset
global_basis = rot_basis
func take_photo() -> void:
if !is_active:
return
var targets = get_tree().get_nodes_in_group("collectible")
var space_state = get_world_3d().direct_space_state