![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Coenster |
Hello
I’m still using Godot 2.1.4 because of GLES2 not being in GODOT3
I want to drag across the screen to pan the camera and limit the camera not to pan to far. This is what I’ve got:
func pan_camera(val):
var p = get_node("Camera").get_pos()
var pan = current_pan_move * pan_rate
p.x = clamp(p.x + pan, -150, 150)
get_node("Camera").set_pos(p)
This obviously only pan the x axis, and no matter what I add, i can’t pan the x and y axis at the same time. I did use this code to pan and use the camera limit to prevent the camera from scrolling too far:
if event.type == InputEvent.MOUSE_MOTION:
move_local_x(-event.relative_x)
move_local_y(-event.relative_y)
But this was a nightmare, it messed with my zoom(didn’t zoom to the center of my scene anymore, couldn’t fix it) and the camera got stuck whenever it reached the pan limit.
How can my first code be edited to allow the camera to pan on x and y axis?
If you have better way to pan the camera with SCREEN_DRAG and I will appreciate it.
Did you find a solution in the meantime?
TobiLa | 2018-07-20 09:08