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
Events can use 8-dir sprites. And of course, you can trigger events diagonally. If you have 8-directional vehicles, they are also supported.
Do you have large sprites? No problem, it supports large sprites as well.
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.
Script: download here
- Patch for Modern Algebra’s Extra Movement Frames
Interested in how it is written? Read the dev log for this script!
- Part 1 – Introducing Diagonal Movement into RPG Maker
- Part 2 – Diagonal Movement and Character Interaction
- Part 3 – Diagonal Movement and Movement Speed
- Part 4 – Diagonal Movement and Large Sprites
In the script editor, place this script below Materials and above Main
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.
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)
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.
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.
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.
Is this free to commercial use?
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.
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
# alias method: self.dir4
class <<self; alias helladen_dir4 dir4; end
return 2 if Input.press?(:Y)
return 4 if Input.press?(:X)
return 6 if Input.press?(:Z)
return 8 if Input.press?(:R)
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]]
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?
the image didn’t post for some reason so here’s a link to it.
I can’t think of a solution for this beyond 8-dir passage settings. However, I’m not sure if there is a script for that.
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
Filenames with $ won’t work here. You will need to resize the image to match the format shown in the example.
Oh, thanks! It works perfeclty now. Excelent script :3
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!!
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.
The script doesn’t support multi-frame characters. You will need a patch to work with the script you’re using.
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”
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)
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)
@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))
if horz == 4
if vert == 2
elsif vert == 8
elsif horz == 6
if vert == 2
elsif vert == 8
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!
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?
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.
Could it be your keyboard?
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.
Galv’s jump script does not support diagonal jumping.
Fair enough, sorry about the double posting.
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.
For those using Modern Algebra’s extra animation movements, I’ve written a patch so that extra animations also apply to diagonal frames.
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?
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.
Oh wow, that was pretty much the fastest response I’ve ever got from a scripter! 😛 Thank you so much! <3
It works like a charm!
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:
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/)
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.
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:
And the fly script I’m using from above or here:
The extra animations can be found here:
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/)
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.
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!
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 ^^
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.
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
That’s exactly why it’s happening: because you copy and paste without changing anything. Read the instructions.
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?
It works with any character size as long as the sheets are 3×4 and you have 8 blocks per image.
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 ?
Additional animation modes would require additional scripts. This one simply takes your default 4-dir movement and adds some diagonal movement.