movement issue (specifically moving down)

Discussion in 'Programming' started by 0bzidien, Jul 10, 2019.

Tags:
  1. 0bzidien

    0bzidien Member

    Joined:
    Jul 10, 2019
    Posts:
    4
    Hi all, i'm having an issue that is beyond my (almost 0) experience with Gamemaker.
    im trying to code movement using GML. It works perfectly except for moving left and right. but when i run up or down my character runs diagonally instead of along the y axis. If I remove the sprite animation the character moves correctly. Thanks for any help

    if keyboard_check(ord("W"))
    y -= 1

    if keyboard_check(vk_shift) and keyboard_check(ord("W"))
    y -= 2

    if keyboard_check(vk_shift) and keyboard_check(ord("W"))
    {
    sprite_index = Jennifer_run_up
    speed = 1


    }
    else
    if keyboard_check(ord("W"))
    {
    sprite_index = Jennifer_walk_up
    speed = 1
    }


     
  2. Azenris

    Azenris Member

    Joined:
    Oct 30, 2016
    Posts:
    64
    i feel like you are missing a chunk of code, is there more, this is only the move up code

    did you mean to use speed? maybe you meant image_speed ?
     
  3. 0bzidien

    0bzidien Member

    Joined:
    Jul 10, 2019
    Posts:
    4
    here's a short gif of the issue:
     

    Attached Files:

  4. Azenris

    Azenris Member

    Joined:
    Oct 30, 2016
    Posts:
    64
    definetely seems its the speed vs image_speed problem.
    speed makes the object move in its direction. direction is default 0 = RIGHT.
    once you set the speed, it starts moving right.


    maybe :p
     
  5. 0bzidien

    0bzidien Member

    Joined:
    Jul 10, 2019
    Posts:
    4
    to be honest the code was taken off a tutorial, i assumed the speed was referring to the speed of the animation?
     
  6. 0bzidien

    0bzidien Member

    Joined:
    Jul 10, 2019
    Posts:
    4
    i have no idea how, but that fixed it.
    Thanks :) :) :)
     
  7. Azenris

    Azenris Member

    Joined:
    Oct 30, 2016
    Posts:
    64
    if you retype speed, try hover it and press F1, or maybe middle mouse button. Should give some info on it.
     

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