GML I Couldn't Make Vertical Elevator

Discussion in 'Programming' started by BizonTR, Jul 11, 2019 at 11:50 AM.

  1. BizonTR

    BizonTR Member

    Joined:
    Wednesday
    Posts:
    1
    Hi everyone, I started make a game about 2 weeks ago. I'm beginner in Game Maker. So, I will need a lot of help. Anyway, I want make a vertical elevator. But I failed. I watched some videos about elevator but I couldn't find any idea. Actually, I made elevator moving to up and down but I want too another thing. It is that: When my character was in the elevator, elevator must go down when I pressed (vk_down) and must go up when I pressed (vk_up). How can I do this? I using an obj_blocker. Elevator moving down when elevator hit the obj_blocker. This is for moving down when elevator hit blocker. Also, I using obj_floor for elevator moving up when hit obj_floor. Codes are these.

    obj_character collision obj_elevator event:

    vspeed=other.vspeed;



    obj_character step event:

    if(place_meeting(x,y+1,obj_floor)) or (place_meeting(x,y+1,obj_elevator)){
    gravity=0
    gravity_direction=270
    vspeed=0
    }
    else{
    gravity=0.2
    gravity_direction=270
    }





    obj_elevator create event

    vspeed=1




    obj_elevator step event

    if(place_meeting(x,y-4,obj_blocker)){
    with(obj_elevator)
    {
    vspeed=1;
    }
    }






    obj_elevator collision obj_blocker event:

    if vspeed>0{
    vspeed=-1
    }
    else{
    vspeed=1
    }
    if(place_meeting(x,y-1,obj_character)){
    obj_character.y - =5;
    }






    obj_elevator collision obj_floor event:

    if vspeed>0{
    vspeed=-1;
    }
    else{
    vspeed=1
    }
    if place_meeting(x,y-1,obj_character){
    obj_character.y - =5
    }







     
    Last edited: Jul 11, 2019 at 12:04 PM

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice