DIAGONAL MOVEMENT (WITHOUT USING PRECIOUS NUMBER KEYS!)

How to add diagonal movement to your games.

  • Seena
  • 10/29/2011 06:55 PM
  • 9276 views
Requirments: 2 variables, 1 common event.

Note: This system should not be used in conjunction with the default random encounter system because steps taken diagonally are completely ignored by the built-in step counter.

Steps:

1. Create 2 variables and name one HorizontalKeys and the other VerticalKeys.

2. Create a common event and name it movement or something like that. Make sure the trigger is parallel process, and no switch is used.

3. Add 2 "Key Input Processing" event commands. Make one only process the Up key and the Down key, and store the key code in the VerticalKeys variable. Make the other one only process the Left and Right keys, and store the keycode in HorizontalKeys. Both "Key Input Processing" event commands should NOT have "Wait until key is pressed" selected.

4. Create a "Conditional Branch" that tests if VerticalKeys = 1, with an else handler. In the else handler create another "Conditional Branch" that tests if VerticalKeys = 4, without an else handler.

5. In both branches that test VerticalKeys, create another "Conditional Branch" that tests if HorizontalKeys = 2, with an else handler. In that else handler create another "Conditional Branch" that tests if HorizontalKeys = 3, without an else handler.

6. In all branches that test HorizontalKeys, place a "Move Event" command, make sure it's the Hero that's getting moved, and have it move the Hero once in the diagonal direction the hero should be moving in. Also make sure that the option "ignore impossible movement" is set on all the "Move Event" commands, otherwise the game can freeze of the player diagonally moves against an impassable tile or object.

That's it! The original movement system will still be in place, so don't worry about that.

Posts

Pages: 1
The only thing that will not work well with this system are the normal area/map encounters, because movement caused by events is never counted for the step count.
Also, the user must remember to have "ignore if can't move" checked. If not, the movement will "freeze" constantly.

Nice contribution, cheers,
Orochii Zouveleki
Thanks for letting me know about this. I will fix this tutorial soon. In the mean time users of rm2k3 shouldn't use the movement system in this tutorial with the default area/map random battles unless you want players to be able to avoid battles simply by walking diagonally.
Perfect! This is exactly what my game needed! Thanks very much!
Cool:D Theres probably a simpler way to do it.
My zelda-rpgs could benefit from this tutorial.
I have been thinking of the possibility of adding a decrease move speed in the move events command... Since characters move 32px diagonally and 16px diagonally, they should move twice as slow diagonally. Makes it more...
Less obvious that the diagonal movement is not inbuilt.
I wonder why none have done this, might be because it would make it too slow?

Anyways, clean tut!
That may be a good idea. Even with Hero/Event Collision set to on, sometimes the diagonal movements have been skipping over events. That may fix the problem.
Pages: 1