• 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!

3D Door Opening Problem

R

Rebecca Rodriguez

Guest
The door was opening fine but not closing.
When i added the open and close variables its not working at all.

What is wrong and why is it not working.
USING GM 8.0

obj_door

CREATE
instance_create(x,y,obj_singledoor_wall);
open = false;
closed = true
rot = 90;

STEP
if (distance_to_object(obj_cam) < 64) && (closed == true){
rot -= 1;
closed = false;
open = true;
}

if (rot <= 0)
{
rot = 0;
} else {
if (distance_to_object(obj_cam) > 64) && (open == true){
rot += 1;
closed = true;
open = false;
}
if (rot >= 90){
rot = 90;
}
}

DRAW
if (point_distance(x,y,global.camx,global.camy) > 720) exit;

d3d_transform_set_identity();
d3d_transform_add_rotation_z(rot);
d3d_transform_add_translation(x,y,0);
//back of door
d3d_draw_wall(0,0,24,0,+16,0,background_get_texture(tex_singledoor),1,1);
//front of door
d3d_draw_wall(+2,0,24,+2,+16,0,background_get_texture(tex_singledoor),1,1);
//side of door left
d3d_draw_wall(0,0,24,+2,0,0,background_get_texture(tex_singledoor_side),1,1);
//side of door right
d3d_draw_wall(0,+16,24,+2,+16,0,background_get_texture(tex_singledoor_side),1,1);
d3d_transform_set_identity();
 
M

Maximus

Guest
Not sure if this is the issue, but I see this sort of thing a lot so I thought I'd point it out. Having 2 variables to keep track of the whether the door is open or closed is a bad idea. The door should only be able to be in 1 of 2 states, open or not open. Using 2 variables means that it might be possible for your door to be open and closed at the same time, which doesn't make sense.
 
R

Rebecca Rodriguez

Guest
I gave it a try using only open variable bool either true or false, however it opens but never closes, im assuming its a bad checking using if (distance_to_object(obj_cam) > 64 ) // then some code
 
Top