• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

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

A

Alex H

Guest
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