Game Maker Tutorial – Movement in 8 Directions

[ad_1]
Brand new 2017 Game Maker Studio: 2 Course available right now

Game Maker Tutorial Movement in 8 Direction

In this video we learn about making our player able to move in a full 8 direction. If you have any questions feel free to leave a comment and a like if this Game Maker Tutorial Movement in 8 Directions helped you.

if keyboard_check(vk_up) && place_free(x,y-5) {y-=5}
if keyboard_check(vk_down) && place_free(x,y+5) {y+=5}
if keyboard_check(vk_right) && place_free(x+5,y) {x+=5}
if keyboard_check(vk_left) && place_free(x-5,y) {x-=5}

Follow me on twitter for exclusive content and interaction with me!


Posted

in

by

Tags:

Comments

47 responses to “Game Maker Tutorial – Movement in 8 Directions”

  1. namcokid47 Avatar

    How do you add animations to the code? I want my character to have a walking animation for each direction, but it doesn't seem to be working.

  2. CaptainFalconRacer Avatar

    Wait… did you say third 'gimmick' tutorial?

  3. GoBanaenae Avatar

    how to do it with walk animation

  4. GMDonut Avatar

    know what sucks though i have animation for the player

  5. ColdFire Avatar

    when i do this script and i move in the other 4 directions the speed is 2 times higher …

  6. Yrock - PvP Avatar

    What's inside the step's event ?

  7. lolo133t Avatar

    _________________________________________
    FATAL ERROR in
    action number 1
    of Step Event
    for object obj_player:

    COMPILATION ERROR in code action.
    Error in code at line 1:
    if keyboard_check(vk_up) && place_free(x,y-5) (y-=5)

    at position 49: Symbol ) expected.

  8. Ascaron50 Avatar

    The problem here is that moving diagonally will be faster.

  9. Necromedes Avatar

    You see, my issue is that I have follower objects and when I use this type of coding, the player moves faster when going diagonally. Any suggestions on that?

  10. 24masks Avatar

    what do l do if l want to use w, a, s, d, instead of the directional buttons?

  11. Liam Pullin Avatar

    Worked well, thank you.

  12. AwesomeRepix Avatar

    Left ear is enjoying this.

  13. Nemanja Gega Avatar

    How can i use WASD,not arrows?

  14. Equinox Studio Avatar

    Thanks ! I finally can move my caracter to 8 directions ! I searched the solution for so long! +1 You deserve ! 🙂

    PS: Sorry for Faults I'm not English.

  15. LikaBaws Avatar

    Liked the video! awesome tutorial! can you make more easy tutorial likes this one? very understandable!

  16. Long  Deer Avatar

    Tq.but if you want to press w rather than vk_up how?

  17. Long  Deer Avatar

    Tq.but if you want to press w rather than vk_up how?

  18. Nikhil Tailor Avatar

    what if we wanted to do this with multiple sprite, (not rotating. actually, different sprites) and have walking animations

  19. PogueSquadron Avatar

    I know this is an older video, but I too am using code similar to this so that my character doesn't walk through walls. Is there an easy way of having some more graceful/forgiving "wall hugging?" If you play Chrono Trigger and Crono runs into the edge of a table, he'll slide to the edge until the path is clear and continue on. Do you have any idea how this is accomplished? It feels really clunky otherwise to me.

  20. Dave MacLellan Avatar

    Hello just curious to why use keyboard_check(vk_ instead of keyboard_check(ord. is it because it is arrows and not a character? Thanks

  21. Minseo Kwon Avatar

    i love uuuuuuuuu!!!!
    but no homo

  22. KobraLightGaming Avatar

    What about hitting something, why doesn't it do anything but stop me?

  23. braeden Bounds Avatar

    Mine says error at line 3 pos 50: Symbol ) expected what's that supposed to mean???

  24. GetSpiffy Avatar

    i feel dumb i was missing that last ")" at the end of the first line copy the code if you want it works just remember the event is step and thats it also the code is from the flash light episode

  25. GetSpiffy Avatar

    Will someone tell me whats wrong with this code

    image_angle = point_direction(x,y,mouse_x,mouse_y

    if keyboard_check(vk_up) && place_free(x,y-5) {y-=5}
    if keyboard_check(vk_down) && place_free(x,y+5) {y+=5}
    if keyboard_check(vk_right) && place_free(x+5,y) {x+=5}
    if keyboard_check(vk_left) && place_free(x-5,y) {x-=5}

    please

  26. jim bob Avatar

    helped so much thanx

  27. Suspence Avatar

    sub dude your awesome!

  28. Pile Avatar

    did you put it in step event?

  29. RealTutsGML Avatar

    No worries. Have fun programming 🙂

  30. RealTutsGML Avatar

    Yeah if you read the other comment it will show you that the description would not let me add the full code. Put this in there I was missing a &&
    if keyboard_check(vk_up) && place_free(x,y-5) {y-=5}
    if keyboard_check(vk_down) && place_free(x,y+5) {y+=5}
    if keyboard_check(vk_right) && place_free(x+5,y) {x+=5}
    if keyboard_check(vk_left) && place_free(x-5,y) {x-=5}

  31. TheSuperPhat Avatar

    if keyboard_check(vk_up) && place_free(x,y-5) {y-=5}
    if keyboard_check(vk_down) && place_free(x,y+5) {y+=5}
    if keyboard_check(vk_right) && place_free(x+5,y) {x+=5}
    if keyboard_check(vk_left) && place_free(x-5,y) {x-=5}

    Changed the code. He forgot to put the "&&" in it.

  32. XxThornoXx Avatar

    My if keyboard check says its red and error at position 2 or something

  33. AdventuresBytes Avatar

    when i try place in that code i can't move? help?

  34. 4kin0 Avatar

    i have a question. with this example is possible collide with a ramp (diagonally ) and move over this in a smooth movement?

  35. asdga adsgadsgsagd Avatar

    When i do this it actually adds the 2 speeds together when i walk diagonally, making the speeds way larger than they should be, help pls

  36. RealTutsGML Avatar

    its image_index = 1 not image_number

  37. Eric Freeman Avatar

    im trying to make my character change images when he moves. yes i have looked at your tutorials on changing images with image_index, and image_speed, and image_number. but whenever i put image_number=0, i get an error message saying i cant set that variable. But if i dont the image cycles through without a direction being pressed. i have been working on this forever, i have read teh GMl Help file and i still cant figure it out. My image has 4 images, four directions using WASD keys. I need help

  38. 1jazaki Avatar

    Hey I am having a problem with my directional attacking for my plat former it only attacks in one direction do you have a solution

  39. RealTutsGML Avatar

    if keyboard_check(ord("W")) && place_free(x,y-5) y-=20
    if keyboard_check(ord("S")) && place_free(x,y+5) y+=20
    if keyboard_check(ord("D")) && place_free(x+5,y) x+=20
    if keyboard_check(ord("A")) && place_free(x-5,y) x-=20

  40. GaminGod246 Avatar

    HELP PLZ ASAP
    how do i make it so that i can do wasd instead of left,right,up,down

  41. JuleSan jk Avatar

    Yes there is, but not that fatal 😉
    "ERROR at line 5 pos 50: Unexpected symbol." – Well, there is just a "Minus" , so go ahead to delete it and you`ll see: It works 😀

  42. AAETCMLK Avatar

    Hey man nice tutorial, but I was wondering how to do movement with the wasd keys instead of the arrow keys?

  43. isabellarocks1000 Avatar

    ok thanks bud i really appreciate it

Leave a Reply

Your email address will not be published. Required fields are marked *