Need help with RPG character walking animation

Discussion in 'Legacy GameMaker Community Tech Support' started by AYoshiGuy, Dec 25, 2019.

  1. AYoshiGuy

    AYoshiGuy Member

    Joined:
    Dec 25, 2019
    Posts:
    3
    Hey, i am trying to make a RPG game and i can't make the main character's walking animation. I have tried tutorials, my coding skills and other stuff but i just can't do it. Just help me please.
     
    SilentxxBunny likes this.
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,792
    How about NOT skipping steps this time and learn the basics of GML before using a tutorial? Making vague "just help me please" pleas is not how things work around here.

    Learn the syntax first. Then instead of blindly copying the code from a tutorial, walk through the code yourself and see where everything leads. Then the idea should become clear to you.

    Here is an example of what walking animations may look like (excluding the collision detection code since that tends to be project-specific):
    Code:
    var dx = keyboard_check(vk_right)-keyboard_check(vk_left);
    var dy = keyboard_check(vk_down)-keyboard_check(vk_up);
    
    /* Collision detection code here */
    
    x += dx;
    y += dy;
    
    if (dx == 0 && dy == 0) {
      image_index = 0;
      image_speed = 0;
    } else {
      if (dx > 0) {
        sprite_index = spr_right;
      } else if (dx < 0) {
        sprite_index = spr_left;
      } else {
        if (dy > 0) {
          sprite_index = spr_down;
        } else {
          sprite_index = spr_up;
        }
      }
      image_speed = 1;
    }
    
    Think through some sequences of keyboard input and trace through what happens to sprite_index and image_index as the code is repeated between steps. If you need to write down the process because you can't do it in your head yet, write it down. And if you prefer the code from other tutorials, that's fine too, but do this thought exercise with it.
     
    SilentxxBunny and MaxLos like this.
  3. AYoshiGuy

    AYoshiGuy Member

    Joined:
    Dec 25, 2019
    Posts:
    3
    This helped me a lot!
    I have been working on my games for a couple of months and i couldn't do the animations. Most of the videos are for platformers. I fell like a person who begs because of 'just help me please'. I think i can do better in the future. I need to know everything about GameMaker. I still have a long journey to becoming a good developer. You have inspired me to study for my goal. I have a GML book and i will learn everything on it. Then for the stuff that isn't in it. Thank you. :)

    And also, how can i make my character faster?
    When walking and while holding a key?
     
    Last edited: Dec 26, 2019
    SilentxxBunny likes this.
  4. MaxLos

    MaxLos Member

    Joined:
    Sep 25, 2017
    Posts:
    50
    One way is to just have a speed variable initialized in the Create Event of your player and then check if whatever button you want is being held and if so increase the movement speed. Something like this:
    Code:
    //Create Event
    movespeed = 3;
    
    Code:
    //Frostycat's example but with the movement variable added
    var dx = keyboard_check(vk_right)-keyboard_check(vk_left);
    var dy = keyboard_check(vk_down)-keyboard_check(vk_up);
    
    if keyboard_check(vk_shift) movespeed = 6; else movespeed = 3;
    
    /* Collision detection code here */
    
    x += dx * movespeed;
    y += dy * movespeed;
    
     
    SilentxxBunny likes this.
  5. AYoshiGuy

    AYoshiGuy Member

    Joined:
    Dec 25, 2019
    Posts:
    3
    You guys helped me so much. I thought the GML (GameMaker Language) was easy but now that i see the code that you gave me, it is not as easy as i thought.
    I'm gonna study and learn everything GameMaker Studio 2 has. Thanks!
     
    SilentxxBunny likes this.
  6. SilentxxBunny

    SilentxxBunny Epsilon

    Joined:
    Jun 21, 2016
    Posts:
    131
    I totally understand. It's challenging, but if you make an attempt - someone is almost always willing to help. Stick with it, and may the force be with you.
     
    AYoshiGuy and MaxLos like this.

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