GameMaker Studio 2: Keyboard Movement Tutorial

Поділитися
Вставка
  • Опубліковано 8 вер 2024
  • We will be looking at the best practices and basic ways to create keyboard movement in GameMaker Studio 2. This is a perfect beginner tutorial for people who want to start making GameMaker Games!

КОМЕНТАРІ • 37

  • @Themplez
    @Themplez Рік тому +1

    wow this still works thank you

  • @bananamonkey6926
    @bananamonkey6926 5 років тому +6

    Jesus Christ, I have been trying to do this kind of thing for ages, but everyone made it so god damn complicated. Thank you so much for the simple but very effective video!

  • @TomiShow
    @TomiShow 5 років тому +31

    Use it like this,its better
    if(keyboard_check(ord("D"))) x+=6;
    if(keyboard_check(ord("A"))) x-=6;
    if(keyboard_check(ord("S"))) y+=6;
    if(keyboard_check(ord("W"))) y-=6;

    • @SuDzD
      @SuDzD 3 роки тому +2

      Thank you my friend

    • @Nyo-ho
      @Nyo-ho 3 роки тому

      You also can use: switch(keyboard_key)

    • @tunaan80
      @tunaan80 2 роки тому

      Why didn't this work?
      Walking_Spead_Halon = 5;
      image_speed = 0;
      image_index = 2;
      if(keyboard_check(ord("A"))){
      x -= Walking_Spead_Halon;
      image_index = 3;
      }
      if(keyboard_check(ord("S"))){
      y += Walking_Spead_Halon;
      image_index = 2;
      }
      if(keyboard_check(ord("W"))){
      y -= Walking_Spead_Halon;
      image_index = 0;
      }
      if(keyboard_check(ord("D"))){
      x += Walking_Spead_Halon;
      image_index = 1;
      }
      if(keyboard_check(vk_shift)){
      Walking_Spead_Halon = 10;
      }

    • @AltDel
      @AltDel 2 роки тому +1

      thank you soooooooooooooooo much, i was looking for this like, or 20 minutes already, you are my savior

    • @felzaa1934
      @felzaa1934 2 роки тому

      its easier to use a variable since if you want to change the speed you dont have to go in and change every single 6

  • @Broncos_Nation
    @Broncos_Nation 2 роки тому

    I’ve been doing this for like eight hours and it’s literally from five years ago thank you

  • @magegames6202
    @magegames6202 3 роки тому +1

    I just started learning gms2 and I had a feeling I new how to code movement with out any help and I'm glad I was right watching this confirmed I'm actually learning

    • @Etredal
      @Etredal  3 роки тому

      Awesome good work!

  • @enzoferreiraalmeida4178
    @enzoferreiraalmeida4178 2 роки тому

    thanks bro your video is perfect

  • @therealseanw.stewart2071
    @therealseanw.stewart2071 6 років тому +8

    Thank you so much!! This is so basic, I'm still just starting to learn how to program;

    • @palmfruit2955
      @palmfruit2955 6 років тому

      stop the ; at the end of your sentence please. its kinda cringey to out coding community. Sorry if I came across as rude, for I am not trying to be
      thanks

    • @DrMatta
      @DrMatta 6 років тому +1

      you just seem like a whiner

    • @2guys1asian
      @2guys1asian 5 років тому

      fuck off m8;

  • @SageNode
    @SageNode 6 років тому +2

    this is actually much better and neater. In the event type (create) use this code
    keyboard_set_map(ord("W"), vk_up);
    keyboard_set_map(ord("A"), vk_left);
    keyboard_set_map(ord("S"), vk_down);
    keyboard_set_map(ord("D"), vk_right);

  • @indiepixels2261
    @indiepixels2261 5 років тому

    This video helped me the most. Thank you

  • @josephmclean4989
    @josephmclean4989 6 років тому +1

    That was amazing thank you so much it’s so simple

  • @amsy1237
    @amsy1237 2 роки тому

    how could I do it time delayed like when I press the button that makes the player object not directly move forward but charge a number that estimates how far and fast the player object goes into a direction?

  • @saness7702
    @saness7702 4 роки тому +1

    How do you make it wasd?

  • @starmanjr.9747
    @starmanjr.9747 5 років тому

    This is pretty great movment system, but can u make video how to set collisions with that system? (Or write it)

  • @xentus5515
    @xentus5515 6 років тому +2

    I want the WASD keys to control my character, but all the tutorials on youtube do it in code, and i want to do it in drag and drop
    plz help :(

    • @batatereluelimusic
      @batatereluelimusic 6 років тому

      its actually really easy. you just make a key press event for each key and assign the move fixed action in the direction you want it to. you also need to do the same thing except with key release, and set the fixed movement speed to 0 so it stops. this makes some buggy movement but if you're looking for a way to use drag and drop, its the way to go.

    • @SeanStinksAtRoblox
      @SeanStinksAtRoblox 4 роки тому +2

      I can give you some code:)
      if (keyboard_check(ord("D"))) {
      x += walkspeed;
      image_speed = walkspeed/ 3;
      sprite_index = SPRITE;

      }if (keyboard_check(ord("A"))) {
      x -= walkspeed;
      image_speed = walkspeed/ 3;
      sprite_index = SPRITE;

      }if (keyboard_check(ord("S"))) {
      y += walkspeed;
      image_speed = walkspeed/ 3;
      sprite_index = SPRITE;

      }if (keyboard_check(ord("W"))) {
      y -= walkspeed;
      image_speed = walkspeed/ 3;
      sprite_index = SPRITE;
      }
      if(keyboard_check(vk_nokey)) {
      image_speed = 0;
      image_index = 0;
      walkspeed = 3.5;
      }
      if(keyboard_check(vk_shift)) {
      walkspeed = 7;
      }

  • @NightNinja
    @NightNinja 6 років тому

    This works nicely but is there a way to control objects with wasd with this code

  • @Armetron
    @Armetron 6 років тому

    So the problem with this movement is that if you press both a vertical key and a horizontal key you will be traveling faster than if you only pressed on of the keys.
    Let's say speed was set to 5, by pressing up and right the player would be going sq(5) + sq(5) = sq(x), x = sqr(50) = 7.071
    The player would be traveling at about 7.071

    • @sheshin
      @sheshin 5 років тому

      maybe its a bit late, but there has to be a way to say, set a maximum speed, and make the game check if the actual speed is above the maximum, set the speed back to the maximum

  • @matter3206
    @matter3206 3 роки тому

    When i press run and it opens, i dont move

  • @Musaybio_dev
    @Musaybio_dev Рік тому

    it didnt work for me :(

  • @bloodyseba7012
    @bloodyseba7012 5 років тому +1

    no no no no

  • @LeoScript18
    @LeoScript18 4 роки тому

    No te entendí ni vergas, no sé inglés :c

  • @markblackmore6474
    @markblackmore6474 6 років тому

    144p are you serious

    • @woozy_
      @woozy_ 4 роки тому +1

      just your internet lmao