Need help with RPG character walking animation

AYoshiGuy

Member
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.
 

FrostyCat

Member
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.
 

AYoshiGuy

Member
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:

MaxLos

Member
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?
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;
 

AYoshiGuy

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

Member
Now there's a problem. When walking, some of the character's pixels disappear. Maybe the Pixels went outside of the sprite. I tried to move the character and made the sprite a little bigger, but these things do not work. This problem doesn't happen when running.
Also, when i am NOT moving and standing on SOME tiles, the character's legs clip through the tiles. The Instances layer where my character is, is above the tiles layer.
 
Top