Eight Directional Movement

EightDirMovement1

By default, the game only allows you to move in the four orthogonal directions: up, left, down, right.

This script provides support for eight-directional movement in your game, adding support for  diagonal movement. To move diagonally, hold down two direction keys simultaneously.

This script also adds support for eight-directional character sprites,  allowing you to face the appropriate direction when you are moving diagonally.

Followers can use 8-dir sprites

EightDirMovement6

 

Events can use 8-dir sprites. And of course, you can trigger events diagonally. If you have 8-directional vehicles, they are also supported.

EightDirMovement15

Do you have large sprites? No problem, it supports large sprites as well.

.EightDirMovement20

If you just want to be able to move diagonally, you do not need diagonal sprites to use this script. They will simply walk diagonally using one of the orthogonal sprites.

Download

Script: download here

Tutorials

Interested in how it is written? Read the dev log for this script!

Installation

In the script editor, place this script below Materials and above Main

Usage

In the configuration, you can choose whether you want to use diagonal sprites or not by setting the Use_8Dir_Sprites option to true or false. If it’s true, then diagonal sprites will be used. If it’s false, they will not be used.

If you don’t use diagonal sprites, then you can still walk around diagonally, but the sprites will be facing one of the orthogonal directions.

Spritesheet Specifications

Diagonal sprites require you to follow a specific sprite-sheet format. It assumes you are using the default 3×4 character format on a 12×8 character sheet. This means that if each sprite was 32×32 in size, then your image will be 384×256 in dimensions.

Adding Diagonal Sprites

A full character sheet for one character consists of the orthogonal directions as well as the diagonal directions. You will first place your orthogonal sprites onto the sheet, and then right beside it, place your diagonal sprites.

The sprite directions should be as follows (the index is for reference only assuming it is the first character on the sheet)

EightDirMovement17

This means that you can have up to 4 characters per sheet, though I would recommend reserving one sheet per character set. Note that this example does not reflect how the full image appears; I have cropped it for clarity.

Larger Sprites

If you are using sprites that are larger than 32×32 (or smaller), those are also supported. As usual, you need to follow the same specifications. For example, if each sprite was 64×32, then you would have a 192×192 sheet for one set of animations, and then you need to expand that to a 768×256 sheet to meet the specifications.

If you’re having trouble with your sprites, read part 4 of the dev log to see how it works.

Enable Switch

In the configuration, you can choose a specific switch to use to determine whether 8-dir movement is enabled. When the switch is ON, 8-dir movement is enabled. If the switch if OFF, then 8-dir movement is disabled.

You may also like...

52 Responses

  1. gold in ira says:

    I’d like to thank you for the efforts you have put in writing this site.

    I am hoping to see the same high-grade blog posts by you in the future as
    well. In fact, your creative writing abilities has encouraged
    me to get my own, personal blog now 😉

  2. Charleslot says:

    Забудьте о низких позициях в поиске! Наше SEO продвижение и оптимизация на заказ https://seosistemy.ru/ выведут ваш сайт в топ, увеличивая его видимость и привлекая потенциальных клиентов. Индивидуальный подход, глубокий анализ ключевых слов, качественное наполнение контентом — мы сделаем всё, чтобы ваш бизнес процветал.

  3. LazaroArike says:

    Забудьте о низких позициях в поиске! Наше SEO продвижение https://seopoiskovye.ru/ под ключ выведет ваш сайт на вершины Google и Yandex. Анализ конкурентов, глубокая оптимизация, качественные ссылки — всё для вашего бизнеса. Получите поток целевых клиентов уже сегодня!

  4. FrankFem says:

    Услуга сноса старых частных домов и вывоза мусора в Москве и Подмосковье под ключ от нашей компании. Работаем в указанном регионе, предлагаем услугу разборка дома в московской области. Наши тарифы ниже рыночных, а выполнение работ гарантируем в течение 24 часов. Бесплатно выезжаем для оценки и консультаций на объект. Звоните нам или оставляйте заявку на сайте для получения подробной информации и расчета стоимости услуг.

  5. Please let me know if you’re looking for a article writer for your
    site. You have some really good articles and I think I
    would be a good asset. If you ever want to take some of the load off,
    I’d really like to write some material for your blog in exchange for
    a link back to mine. Please shoot me an e-mail if interested.
    Regards!

  6. I just like the helpful info you provide to your articles.
    I will bookmark your weblog and test once more right here regularly.
    I’m slightly sure I will be told plenty of new stuff right right here!
    Best of luck for the following!

  7. I love looking through an article that can make people think.
    Also, thank you for allowing me to comment!

  8. This is the right webpage for anybody who really wants to understand this topic.
    You know a whole lot its almost tough to argue with you
    (not that I personally will need to…HaHa).

    You certainly put a new spin on a subject which has been discussed for ages.
    Wonderful stuff, just excellent!

  9. Thank you for the good writeup. It in truth was a amusement account
    it. Glance advanced to more added agreeable from you!
    However, how could we keep in touch?

  10. Grentos says:

    Is this free to commercial use?

  11. Serac says:

    Hi! I have a little question, how can i deactivate the up and down movement?
    because i want to make a isometrical hexagonal direcctions for a project im have.

  12. jfields99 says:

    I am enjoying this script very much, and was wondering how to add a simple compatibility with a WASD Movement script?
    WASD Movement script follows:

    #==============================================================================
    # ▼ WASD Movement
    # -- Last Updated: 2014.02.25
    # -- Author: Helladen
    #==============================================================================

    module Input
    #--------------------------------------------------------------------------
    # alias method: self.dir4
    #--------------------------------------------------------------------------
    class <<self; alias helladen_dir4 dir4; end
    def self.dir4
    return 2 if Input.press?(:Y)
    return 4 if Input.press?(:X)
    return 6 if Input.press?(:Z)
    return 8 if Input.press?(:R)
    helladen_dir4
    end
    end

    • Hime says:

      That script you posted doesn't support diagonal input. I would recommend using full keyboard input for this, by mapping WASD to the direction keys.

      Line 162 of the script might look like this if you wanted both arrows and WASD

      UP = [KEYMAP[:UP], KEYMAP[:LETTER_W]]
      DOWN = [KEYMAP[:DOWN], KEYMAP[:LETTER_S]]
      LEFT = [KEYMAP[:LEFT], KEYMAP[:LETTER_A]]
      RIGHT = [KEYMAP[:RIGHT], KEYMAP[:LETTER_D]]

  13. Thegrop says:

    Would it be possible to disable diagonal walking on passable tiles perpendicular (not sure if that’s the right word) to X tiles? I’m not sure how to explain it in words so here’s a diagram. (The red Xs mean no passability tiles.)

    Basically I want to disable walking diagonally over tiles that are right next to a tile with no passability, for eventing reasons. Would that be possible?

  14. Lo says:

    Err, sorry for that, but… how do I name the diagonal sprite? Some suffix? Like, sprite name is “$Actor”, then do I name the diagonal sprite “$Actor_something”? I have read the script but I didn’t found about this… actually I don’t understand english soooo well x_x

  15. Doodleturd666 says:

    Hey sorry to be such a dummy (I’m a total noob)
    But wtf am I supposed to patch on the multi frames??
    I have your 8 directional movement script and I have modern algebra’s multiple frames…
    However, I have no idea what to do with your patch!
    Lemme know thanks!!

    • Panqueque says:

      Im having the same issue,please help us 🙁
      The characters keep moving with 3 frames(my animations are made with 6 frames)and in diagonal movement uses the next 3 frames of the same animation,im sorry,but i dont know how to explain it better…
      anyway,thanks for creating this script and i hope you can help.

      • Hime says:

        The script doesn’t support multi-frame characters. You will need a patch to work with the script you’re using.

        • werwers says:

          you made and posted a patchto it, they are asking what to do with YOUR PATCH that YOU made and YOU POSTED labeling it as “Patch for Modern Algebra’s Extra Movement Frames”

    • Hime says:

      You should be able to just insert both scripts in your project and it should work. If it doesn’t work then something may have changed on the other script, or it wasn’t working in the first place (which would be strange)

  16. Benjamin says:

    Hey Hime thanks so much for the script. I’ve found one optimization that you could make, and that is to move the direction facing to the end like this:

    def move_diagonal(horz, vert)
    @move_succeed = diagonal_passable?(x, y, horz, vert)
    if @move_succeed
    @x = $game_map.round_x_with_direction(@x, horz)
    @y = $game_map.round_y_with_direction(@y, vert)
    @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
    @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
    increase_steps
    else
    check_event_trigger_touch_front
    end

    if horz == 4
    if vert == 2
    set_direction(1)
    elsif vert == 8
    set_direction(7)
    end
    elsif horz == 6
    if vert == 2
    set_direction(3)
    elsif vert == 8
    set_direction(9)
    end
    end
    end

    This is because the direction of the player should be calculated even if there’s no move. For example if you walk diagonally into a wall, it should still face diagonally into the wall, because that’s how all the other directions work.

    Cheers, and thanks for the script!

  17. Otaku-kun says:

    Hi Tsukihime.

    Im having the same problem as Cheeky Moon. (Your 8 directional movement script and galv’s character animation script) I also checked in the issues and bug report section but i didnt see anything about this. Do you think you could make a patch for this?

  18. Rizzle says:

    Hey, I really like this script. I also really appreciate all the tutorial stuff. It’s quite fascinating. I just have a simple question. Is there a reason why even on a new project I can’t run diagonally up and to the left? Every other direction works flawlessly. I’ve had this situation with other scripts as well, but I like yours the best.

    • Hime says:

      Could it be your keyboard?

      • Rizzle says:

        That is absolutely the problem… Thanks for the quick response. Now for another simple question. Would you be willing to make this script compatible with Galv’s Jump Script? I would be so grateful, but I would understand if you weren’t taking compatibility requests as well.

      • Rizzle says:

        Yeah, that’s the exact problem. I’m pretty sure I wrote another response, but that was hours ago and it’s still not showing up… I’m glad to see you’re still active. I may be wanting to use some of your scripts in a commercial project. I’ll let you know which ones I’m using eventually here.

  19. Hime says:

    For those using Modern Algebra’s extra animation movements, I’ve written a patch so that extra animations also apply to diagonal frames.

  20. NoizeDaemon says:

    He ho! Awesome script!
    Anyways, I got a question: I plan to only use 8-way-movement on the world map – is there any possibility to enable that movement only for specific map-IDs?

    • Hime says:

      I’ve updated the script to support enabling or disabling 8-dir movement using a switch. You will have to determine when to turn this switch on or off.

  21. Cheeky Moon says:

    I got a little question, are this diagonal movement compatible with extra animations?
    Or is there a small chance that it will be added?
    I want a Idle pose, walking, running and jumping animation.
    I may want to add the flying script of galv from here:
    http://galvs-scripts.com/2012/11/12/superman-ability/

    I never found any diagonal movement script that is compatible with Galv’s flying script. :/
    I want to fly in specific regions. So much for the planning and thank you in advance. 😀 (\s/)

    • Hime says:

      The way the script is designed is that you have your orthogonal frames in one sheet, and then you have your diagonal frames beside it. There was no particular reason behind this design beyond me choosing something that works. It also assumed you used the default character format. If you have “extra” animations, you’d have to specify what that means and how it looks.

      So theoretically as long as you can place your extra animations in a ortho/diag pattern, it will work.

      Galv’s script does not seem to be changing the way movement is handled so as long as you follow the format with his “_fly” suffix it should work.

      • Cheeky Moon says:

        I was talking about extra animations, like standing, walking and running. The second thing that is allready implemented in my RPG, is that all animations have 6 frames instead of 3. In basic I asked about, how can I use diagonal movement and 6 frame animation. Tried to change some lines in the script, but somehow only messed stuff up. :/
        Really sorry for the late answer, at the moment I’m using Victor Sant scripts for animations like stance, walking, running and jumping also I do so for diagonal movement and 6 frame animations. But Victor Sant’s scripts seems not to be compatible with the flying script of Galv. 🙁
        I got an alternative 6 frame animation from Modern Algebra here:
        http://rmrk.net/index.php/topic,46822.0.html
        And the fly script I’m using from above or here:
        http://galvs-scripts.com/2012/11/12/superman-ability/
        The extra animations can be found here:
        http://galvs-scripts.com/2012/10/04/character-animations/

        What I want is animations for jumping, walking, running, flying, idle with 6 animation frames and diagonal movement. Hope I writen it clear enough. Really sorry for the late reply. :'( (\s/)

        • Hime says:

          Create a new project with the scripts you want and some characters set up with your character format. Then send it to me using the “contact me” form in the navbar at the top of the page.

          • Alopex says:

            Did you ever get this to work? I also happen to be using that same script of galv’s and would love to implement diagonal sprites as well!

  22. Mireneye says:

    Any advice on how i can turn/convert a single character sheet, using $ at 512X288, each sprite is 128×96. Been trying quite a bit but cant quite figure it out. Grateful for any pointers, help. Read the blog but still seemingly unable to fully apply the knowledge. Thanks ^^

    • Hime says:

      I’m assuming the width is 288 and height is 512. Multiply the width by 4 and the height by 2 to get the size of the image if there were 8 of those sheets on the same image.

  23. Zolex Szeto says:

    erm… my character went invisible when i move at 2,4,8,10 clock direction or east south direction why does this happen i copy and paste without changing anything pls reply asap thanks

  24. Ian Bach says:

    hello I een trying to make this script work but I have chars that are 64×32 in size. does this script only work with the 32 x 32 type char sets?

    • Hime says:

      It works with any character size as long as the sheets are 3×4 and you have 8 blocks per image.

      • Ian Bach says:

        I figured out what was wrong.
        so first sprite i made was 3×4 with a 3×4 so one 3×4 was up down etc other was diagonal movements. i tried it without $ with $ with ! and nothing in front of file name no joy.
        so then i figured out it need to be set on a file/picture that is big enough for 8 3×4 sprite sheets. these have no prefix i.e. $ it is just normal file name. so i set the up down to top left 3×4 area and diag moves to the right of that sprite.

        ? is there a way to make to change the sprites when char runs? so 8 dir walk 8 dir run? I ask because some of the sprites I have from one of the rpg maker packs has run and walk all 8 direction. it also has ones that are like 7-9 moves 3 or 4 rows moves are coloumns per say. looks like they are for combat moves. then one sprite sheet has 4 moves looks like char lying down or dead ?

        • Hime says:

          Additional animation modes would require additional scripts. This one simply takes your default 4-dir movement and adds some diagonal movement.

Leave a Reply to Panqueque Cancel reply

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