movement issue (specifically moving down)

0

0bzidien

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


 

Azenris

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

Azenris

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

0bzidien

Guest
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 ?
to be honest the code was taken off a tutorial, i assumed the speed was referring to the speed of the animation?
 
0

0bzidien

Guest
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.
i have no idea how, but that fixed it.
Thanks :) :) :)
 

Azenris

Member
if you retype speed, try hover it and press F1, or maybe middle mouse button. Should give some info on it.
 
Top