Windows GameMaker Studio 2: Complete Platformer Tutorial (Part 6: Cameras & Tiles) - Issues

Alex H

Member
The camera puts my character at the most bottom-right corner of the screen, not the center. Any tips? Thanks. My code is:

cam = view_camera[0];
follow = obj_player;
view_w_half = camera_get_view_width(cam) + 0.5;
view_h_half = camera_get_view_height(cam) + 0.5;
xTo = xstart;
yTo = ystart;

if (instance_exists(follow))
{
xTo = follow.x;
yTo = follow.y;
}

x += (xTo - x) / 25;
y += (yTo - y) / 25;

camera_set_view_pos(cam,x - view_w_half,y - view_h_half);
 
Top