D
Daveb21st
Guest
I am working on a 2 player platformer.
//Tracking// Centers the camera position perfectly.
But both together mess up the centering...
Everything works fine until I add the //Zoom// section, which messes up the camera position.
But I don't know why. I have tried many things and yet the camera never centers between the players when //Zoom// is added.
...unless I delete //Zoom// and then it centers perfectly again.
help?
- I want my two characters to be seen in the camera
- and to zoom in and out according to their x distance
//Tracking// Centers the camera position perfectly.
But both together mess up the centering...
Everything works fine until I add the //Zoom// section, which messes up the camera position.
But I don't know why. I have tried many things and yet the camera never centers between the players when //Zoom// is added.
...unless I delete //Zoom// and then it centers perfectly again.
help?
GML:
//Get camera width
var cam_w = camera_get_view_width(view_camera[0]);
var cam_h = camera_get_view_height(view_camera[0]);
//Player position shortcut
var p1x = obj_player_1.x;
var p1y = obj_player_1.y;
var p2x = obj_player_2.x;
var p2y = obj_player_2.y;
//Player H-distance
var xptp = abs(p2x - p1x);
//Center camera between players
if instance_exists(obj_player_1) && instance_exists(obj_player_2) {
x = (p1x + p2x) * .5;
y = (p1y + p2y) * .5;
}
//Zoom
camera_set_view_size(view_camera[0],xptp,xptp*.75);
//Tracking
camera_set_view_pos(view_camera[0],x - cam_w*.5,y - cam_h*.5);