• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

SOLVED Need help with RPG character walking animation

A

AYoshiGuy

Guest
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

Redemption Seeker
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.
 
A

AYoshiGuy

Guest
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 by a moderator:

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;
 
A

AYoshiGuy

Guest
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.
 
A

AYoshiGuy

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

edit: The problem was the speed. The bug happened because the character was fast.
 
Last edited by a moderator:
Top