GMS 2 [Solved] Camera snapping to previous location when moving after moving it to other places

Edit 1: Guess i just needed to post it here to change my perspective on the thing.
Since i use
x += floor((xTo-x)/5);
y += floor((yTo-y)/5);
i had to add
x = viewposX;
y = viewposY;
in the initialization of the variables in my Global Right Down method.

I have two objects which both have a method that moves the camera.
The first is my regular camera moving when the right mouse button is held down.
The second one is to let the view jump between different objects in the room.

Individually these methods work just fine, however when i jumped to a point on the map and then try my drag and move method it jumps back the the previous position before resuming the regular movement

Any idea what might cause this?

Movement method (Global Right Down)
cam = view_get_camera(0);

vwidth = camera_get_view_width(cam);
vheight = camera_get_view_height(cam);
viewposX = camera_get_view_x(cam) + (vwidth/2);
viewposY = camera_get_view_y(cam) + (vheight/2);


xTo = viewposX + lengthdir_x(min(200,distance_to_point(mouse_x,mouse_y)),direction);
yTo = viewposY + lengthdir_y(min(200,distance_to_point(mouse_x,mouse_y)),direction);

x += floor((xTo-x)/5);
y += floor((yTo-y)/5);

viewposX = -(vwidth/2) + x;
viewposY = -(vheight/2) + y;

viewposX = clamp(viewposX,0,room_width-vwidth);
viewposY = clamp(viewposY,0,room_height-vheight);

Jumping method (Step method of a different object)
var cam, vwidth, vheight;

cam = view_get_camera(0);
vwidth = camera_get_view_width(cam);
vheight = camera_get_view_height(cam);

for (var i = 0; i < ds_list_size(global.list_mappoints); i++){
    var j = ds_list_find_value(global.list_mappoints,i);
    if point_in_rectangle(device_mouse_x_to_gui(0),device_mouse_y_to_gui(0),80,75+i*30,540,100+i*30) && mouse_check_button_pressed(mb_left)
        camera_set_view_pos(cam, clamp((variable_instance_get(j,"x")- vwidth/2),0,room_width-vwidth), clamp((variable_instance_get(j,"y")-vheight/2),0,room_height-vheight) );

Last edited: