Topic was automatically imported from the old Question2Answer platform.
Asked By
miyatora
Hello!
I’m working on a mobile project.
If I set the rectangle area and drag the screen, I hope the camera will move only in there.
How do you visually represent an rectangle and how to make the camera move only inside the box?
And what should I do to keep the camera from bouncing off rather than stopping suddenly?
Thank you in advance.
func _cameraUpdate() -> void:
var map := mapBounds()
var world := _worldBounds().grow(-_back.cell_size.x)
if not world.intersects(map):
_cameraSnap(_camera.global_position + _constrainRect(world, map))
else:
emit_signal("updateMap")