H
Halas
Guest
hello all,
I am running into an issue with my camera.
CREATE EVENT:
STEP EVENT:
This is the code.
Everything works for the camera, except when I add-in the Clamps:
x = clamp(x,width,room_width-width);
y = clamp(y,height,room_height-height);
If I include this, the camera decides to stop working and is stuck in the room.
Any ideas?
I am running into an issue with my camera.
CREATE EVENT:
Code:
follow = Obj_Player;
cam = view_camera[0]
width = camera_get_view_width(cam) * 0.5;
height = camera_get_view_height(cam) * 0.5;
xTo = xstart;
yTo = ystart;
screenshake = 0;
STEP EVENT:
Code:
/// X and Y
var target_x = follow.x + random_range(-screenshake, screenshake);
var target_y = follow.y + random_range(-screenshake, screenshake);
/// Update Destination
if (instance_exists(follow))
{
xTo = target_x;
yTo = target_y;
}
/// Update Object Position
x += (xTo - x) / 25;
y += (yTo - y) / 25;
x = clamp(x,width,room_width-width);
y = clamp(y,height,room_height-height);
// Update Camera View
camera_set_view_pos(cam, x-width, y-height);
Everything works for the camera, except when I add-in the Clamps:
x = clamp(x,width,room_width-width);
y = clamp(y,height,room_height-height);
If I include this, the camera decides to stop working and is stuck in the room.
Any ideas?