1. Hey! Guest! The 31st GMC Jam will take place between Nov 16th, 12:00 UTC (Friday noon) and Nov 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

SOLVED Walking Animation Trouble

Discussion in 'Programming' started by averytireddad, Nov 7, 2018.

  1. averytireddad

    averytireddad Member

    Joined:
    Nov 7, 2018
    Posts:
    3
    So I am fairly new to Game Maker and I am learning to code as I go, making my first game. I am currently making the walking animations for my main character sprite. When I make my sprite walk forward, the animation plays fine, but when I try to move my sprite left or right, the animation for it does not play, it just shows the idle sprite that I made for when the character is facing left or right. I tried playing with the code a bit and the animation frames as well to see if I could get it to work, but I have not been able to figure it out. I am not sure what the problem is, here's a picture of my code so you can see how I am going about this.
    Again, I'm fairly new to Game Maker, and I'm still learning! Thanks for your help!
     

    Attached Files:

  2. PlayerOne

    PlayerOne Member

    Joined:
    Mar 14, 2018
    Posts:
    217
    If I'm reading the code properly try changing this line:

    Code:
    moveside = keyboard_check(vk_left) + keyboard_check(vk_right)
    
    Add a + and not a - to the line.
     
  3. averytireddad

    averytireddad Member

    Joined:
    Nov 7, 2018
    Posts:
    3
    I've tried this before, but I tried it again just in case, and all it does is make it so when you press the left arrow key, the sprite that faces the side does not flip to face left, it continues to face right. When I have a - instead of a + the sprite flips to face whatever direction the key you are pressing is.
    I have found that the walking animation only plays whenever I press the left or right arrow key with the down arrow key at the same time, and I'm not sure why. Any ideas? I appreciate your help!
     
  4. PlayerOne

    PlayerOne Member

    Joined:
    Mar 14, 2018
    Posts:
    217
    Just check my platform code and I have it written similar to something like this.

    Code:
    moveside = (-keyboard_check(vk_left)) + (keyboard_check(vk_right))
    
    When pressed key left will be a negative (-1) and key right will be a positive (1). Also get rid of image_xscale=move from the line and it should be good.
     
  5. Simon Gust

    Simon Gust Member

    Joined:
    Nov 15, 2016
    Posts:
    2,872
    just as a clearance
    this
    Code:
    moveside = -keyboard_check(vk_left) + keyboard_check(vk_right);
    
    does the same as this
    Code:
    moveside = keyboard_check(vk_right) - keyboard_check(vk_left);
    
     
    PlayerOne likes this.
  6. averytireddad

    averytireddad Member

    Joined:
    Nov 7, 2018
    Posts:
    3
    Thanks everyone for your help! Everything is working properly now!
     

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