# Camera not working in a Game Maker mod I am creating [duplicate]

I wrote an object, in Game Maker. My problem is that the camera appears to be nonexistent. It does not follow the player, and from the perspective it displays on the screen, I believe I simply do not have a camera.

### This is my Step event:

right = keyboard_check(vk_right);
left = keyboard_check(vk_left);
forward = keyboard_check(vk_up);
back = keyboard_check(vk_down);

if (jump==0 && keyboard_check(vk_space))
{
sound_play(snd_jump);
x += 3 * unitZ_x;
y += 3 * unitZ_y;
z += 3 * unitZ_z;
jump = 1;
canjump = 4;
}

canjump -= 0.5;
x += unitZ_x * canjump;
y += unitZ_y * canjump;
z += unitZ_z * canjump;

if (canjump < -8)
{
canjump = -8;
falling = 1;
}

currentRadius = sqrt((x - centerX) * (x - centerX)
+ (y - centerY) * (y - centerY) + (z - centerZ) * (z - centerZ));

{
currentRadius = sqrt((x - centerX) * (x - centerX)
+ (y - centerY) * (y - centerY) + (z - centerZ) * (z - centerZ));
jump = 0;
falling = 0;
canjump = 0;
}

if ((right==1) || (left==1))
{
x += (right - left) * 4 * unitX_x;
y += (right - left) * 4 * unitX_y;
z += (right - left) * 4 * unitX_z;

distance = sqrt((x - centerX) * (x - centerX)
+ (y - centerY) * (y - centerY) + (z - centerZ) * (z - centerZ));

unitZ_x = (x-centerX) / distance;
unitZ_y = (y-centerY) / distance;
unitZ_z = (z-centerZ) / distance;

x -= (distance - currentRadius) * unitZ_x;
y -= (distance - currentRadius) * unitZ_y;
z -= (distance - currentRadius) * unitZ_z;

unitX_x = unitY_y * unitZ_z - unitY_z * unitZ_y;
unitX_y = unitY_z * unitZ_x - unitY_x * unitZ_z;
unitX_z = unitY_x * unitZ_y - unitY_y * unitZ_x;
}

currentRadius = sqrt((x - centerX) * (x - centerX)
+ (y - centerY) * (y - centerY) + (z - centerZ) * (z - centerZ));

if ((forward==1) || (back==1))
{
x += (forward - back)*4*unitY_x;
y += (forward - back)*4*unitY_y;
z += (forward - back)*4*unitY_z;

distance = sqrt((x - centerX) * (x - centerX)
+ (y - centerY) * (y - centerY) + (z - centerZ) * (z - centerZ));

unitZ_x = (x - centerX) / distance;
unitZ_y = (y - centerY) / distance;
unitZ_z = (z - centerZ) / distance;

x -= (distance - currentRadius) * unitZ_x;
y -= (distance - currentRadius) * unitZ_y;
z -= (distance - currentRadius) * unitZ_z;

unitY_x = unitZ_y * unitX_z - unitZ_z * unitX_y;
unitY_y = unitZ_z * unitX_x - unitZ_x * unitX_z;
unitY_z = unitZ_x * unitX_y - unitZ_y * unitX_x;
}


### This is my Draw event:

  d3d_draw_ellipsoid(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1, 0, 1, 1, 60);
d3d_set_projection_perspective(0, 0, 640, 480, 0);
d3d_set_projection(x - 4 * unitY_x, y - 4 * unitY_y, z - 4 * unitY_z, unitY_x,
unitY_y, unitY_z, unitZ_x, unitZ_y, unitZ_z);


Does anyone know what I have done wrong? I think it is a simple 3D camera glitch, but I have never made a camera before (in anything for that matter) so chances are it is something really basic.

• yet again another question down-voted with no context! – Ryan white Nov 1 '16 at 9:19
• @Ryanwhite i know, right? I don't mind down votes but if it's continuing repeatedly at least take a minute to say why. :p – user64742 Jan 6 '17 at 19:19