r/gamemaker•
TheDemonChief

Camera won't follow y axis

Help!

I've been following this tutorial for the camera, and I can't figure out why my Y axis for the camera isn't working properly.

When I'm at the far left corner of the screen, the camera pans upwards and away from the player. At other points in the level/room, the camera doesn't follow the player when they move upwards.

Any help is appreciated! My room transition also stopped working for some reason around this part of programming. Might have to do with changing the room size??

Here's my camera code:

create:

cam = view_camera[0] //names room camera

cam_followspeed = 16 //lower is faster

follow = oEmil

width_half = camera_get_view_width(cam) * 0.5 //find camera center

height_half = camera_get_view_height(cam) * 0.5

xTo = x

yTo = y

step:

//update destination

if (instance_exists(follow)) {

xTo = follow.x

yTo = follow.y

}

//update object position

x += (xTo - x) / cam_followspeed //camera moves slower closer to object

y += (yTo - y) / cam_followspeed

//keep camera from leaving room

x = clamp(x,width_half,room_width-width_half)

y = clamp(x,height_half,room_height-height_half)

//update camera view

camera_set_view_pos(cam,x-width_half,y-height_half)

Posted Sep 8, 2026, 5:00 PM UTC

44
Loading comments…