I need help with camera

im trying to make a game and im trying to get the camera to follow the player without going outside the boundary (the specified boundary is a clip that is on over top of everything but the vcam and is different depending on which level you are on). platformer engine 2.2.510-2-2023_10-37-57.wick

I wont use camera
I’d leave the player still in the center and move the boundary clip

im trying to have the boundary stay still and the camera follow the player but not go past the boundary.

I got the camera itself to work but the actual area you see doesn’t stay in the middle of it.

I would use Math.max and Math.min, in something like this:

camera.x = Math.max( min_X, Math.min(player.x max_X) )
camera.y = Math.max( min_Y, Math.min(player.y, max_Y) )

You can change the values every level or set the boundary to correspond with the size and position of the boundary clip.

could you send a file? I don’t understand how that would work

I did it, but you would probably want to change the boundary clips positions/sizes
metroidvaniaCameraClamp10-4-2023_12-25-27.wick (49.3 KB)

btw, the code is in the vcam clip

thanks, this may help

I might not use it that much in my game though
I may need it in some places though