B
Beggar Studios
Guest
Hey everyone,
I recently upgraded to Game Maker Studio 2 and I noticed there is a new camera system. So I'm trying to revamp my old code so it uses cameras instead of the old views, but I ran into a problem. There is this weird shaking effect when the camera follows the player that doesn't occurs when I'm using the old system. I made 2 gifs to demonstrate this and you can find the code below. Can someone help?
old system (smooth):
http://imgur.com/a/tMynQ
new system with camera (not smooth):
http://imgur.com/a/lIpTR
I recently upgraded to Game Maker Studio 2 and I noticed there is a new camera system. So I'm trying to revamp my old code so it uses cameras instead of the old views, but I ran into a problem. There is this weird shaking effect when the camera follows the player that doesn't occurs when I'm using the old system. I made 2 gifs to demonstrate this and you can find the code below. Can someone help?
Code:
// Creation of the camera and binding it to a view
global.camera = camera_create_view(0, 0, 480, 270, 0, obj_view, -1, -1, 241, 136);
view_set_camera(0, global.camera);
Code:
// Code to make obj_view follow the player
if(obj_player.state == scr_move_state){
var xdis = floor((obj_player.x - x)) * 0.1;
var ydis = floor((obj_player.y - y)) * 0.1;
if(xdis < 0.5 && xdis > 0){
xdis = 0.5;
}
if(ydis < 0.5 && ydis > 0){
ydis = 0.5;
}
if(xdis > -0.5 && xdis < 0){
xdis = -0.5;
}
if(ydis > -0.5 && ydis < 0){
ydis = -0.5;
}
x += xdis;
y += ydis;
}
Code:
// Old code to make the view follow obj_view
// Since the upgrade GM depricated this code so now it looks weird like this
__view_set( e__VW.XView, 0, obj_view.x - __view_get( e__VW.WView, 0 )/2 );
__view_set( e__VW.YView, 0, obj_view.y - __view_get( e__VW.HView, 0 )/2 );
http://imgur.com/a/tMynQ
new system with camera (not smooth):
http://imgur.com/a/lIpTR