GameMaker Camera "Jumping" Back, Mobile Camera Drag Gesture

T

twalkerp

Guest
I'm trying to create mobile camera drag, so once the user zooms in they can drag around the room and view different parts.

It works, but the camera jumps around when dragging, it doesn't feel smooth at all, have to swipe around a bunch to move the camera.

It's like two steps forward one step back.


This is my current code in Global Gesture Drag Start:
Code:
drag_room_x = event_data[? "posX"];
drag_room_y = event_data[? "posY"];
This is my current code in Global Gesture Dragging
Code:
 _x = drag_room_x - event_data[? "rawposX"];
 _y = drag_room_y - event_data[? "rawposY"];
camera_set_view_pos(cam,_x,_y);
Thanks!
 

curato

Member
you can't move it to the camera position to the destination all at once if you don't want the snap. you need to look at where the camera is and where you drug to and move toward the destination. I have gradual move camera in my project. I take the x and y differential of where the camera is and where I want it and divide those numbers by 25 (to avoid the snap bigger is slower) and as long as the numbers don't match then keep move it every frame until you get there. The point is your can't do it all in the same frame or you will get the snap.

In your particular case, if you don't start dragging from the camera origin you will get a jump in the first frame if you aren't close.
 
T

twalkerp

Guest
Thanks!!

Here is the working solution for anyone looking in the future

Code:
camX = camera_get_view_x(cam);
camY = camera_get_view_y(cam);

drag_room_x = camX + event_data[? "rawposX"];
drag_room_y = camY + event_data[? "rawposY"];
 
K

krugen

Guest
Thanks!!

Here is the working solution for anyone looking in the future

Code:
camX = camera_get_view_x(cam);
camY = camera_get_view_y(cam);

drag_room_x = camX + event_data[? "rawposX"];
drag_room_y = camY + event_data[? "rawposY"];
Hi, where should I put this?

If I put this in global dragging, what should I put in global drag start?
 
Thanks!!

Here is the working solution for anyone looking in the future

Code:
camX = camera_get_view_x(cam);
camY = camera_get_view_y(cam);

drag_room_x = camX + event_data[? "rawposX"];
drag_room_y = camY + event_data[? "rawposY"];
Thank you so much!
Just remembering that this code goes at Global Drag Start
 
Top