Files
GGJ26/scenes/camera/camera_controller.gd
minimata da655ed9b7
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 8s
Create tag and build when new code gets to main / Export (push) Successful in 1m13s
Camera control fixes
2026-01-31 13:20:16 +01:00

44 lines
1.0 KiB
GDScript

extends Camera2D
@export_range(0.0, 100) var pan_speed: float = 1.0
var should_move_right = false
var should_move_left = false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
var limit_left_at_center = limit_left + get_viewport_rect().size.x/2
var limit_right_at_center = limit_right - get_viewport_rect().size.x/2
if position.x < limit_left_at_center:
position.x = limit_left_at_center
if position.x > limit_right_at_center:
position.x = limit_right_at_center
if should_move_right:
position.x += pan_speed
if should_move_left and position.x > 0:
position.x -= pan_speed
func _on_pan_right_mouse_entered() -> void:
should_move_right = true
func _on_pan_right_mouse_exited() -> void:
should_move_right = false
func _on_pan_left_mouse_entered() -> void:
should_move_left = true
func _on_pan_left_mouse_exited() -> void:
should_move_left = false