Eli_FixAnalogMove

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,056
Reaction score
439
First Language
Portuguese - Br
Primarily Uses
RMMV

Author Eliaquim

Requirements

SAN_AnalogMove.js

Introduction
Originally the plugin San_AnalogMove.js has a problem with the direction of diagonal movement:
  • When going Up + Right the player turns his direction to the right, but stills go up.
  • When going Down + Left the player turns his direction to the left, but stills go down.
  • When going Right + Down the player turns his direction to down, but stills go right.
  • When going Left + Up the player turns his direction to up, but stills go left.
This can causes issues like the player to open doors that are triggered via player touch while he is facing another direction rather than the door.

Features
Fix direction problem with SAN_AnalogMove.js

How to Use
It's plug and play. Just make sure to put below SAN_AnalogMove.

Download
Eli_FixAnalogMove.js

Credit and Thanks
For this plugin, give the credits to Eliaquim or Rakuen Zero in the credits section of your game.
For the original one, give credits to Sanshiro.
It can be used in free and commercial games.
Do not sell or say that you made this plugin.

Thanks for Sanshiro for this amazing pixel movement plugin!:kaoluv:

Update Log
Version 1.3 - 01/02/2020
- Changes in the code for better readability.
Version 1.2 - 10/01/2019
- Inserted plugin parameter as a workaround for another problem of direction
and movement with the player, when three directional buttons are pressed.
- Updated help file!
Thanks to ShadowDragon.
Version 1.1 - 09/29/2019
- Fix the direction problem of the followers.
Version 1.0 - 09/27/2019
- Plugin release!
 
Last edited:

Wavelength

Pre-Merge Boot
Global Mod
Joined
Jul 22, 2014
Messages
4,698
Reaction score
3,960
First Language
English
Primarily Uses
RMVXA
Approving this thread (and nice video BTW!), but looking through your plugin - are you sure this will work for all cases? Like, if that door were to the right of the player instead of above the player (after walking up-right using diagonal movement), would the player still be able to trigger it? Admittedly I'm not familiar with Sanshiro's script or its alleged flaw, but my understanding of your code is that it is still setting the player's direction to one cardinal direction based on which buttons they had been pressing (and returning from the method before it can evaluate the other cases), and I feel like the player's intention may be one of any two directions they were pressing.
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,056
Reaction score
439
First Language
Portuguese - Br
Primarily Uses
RMMV
If I understand you correctly, yes, the player still be able to trigger it!

Basically what I want to do is the engine to memorize the first direction the player walks.
For example, if he press down then the playeand while moving down the
Approving this thread (and nice video BTW!), but looking through your plugin - are you sure this will work for all cases? Like, if that door were to the right of the player instead of above the player (after walking up-right using diagonal movement), would the player still be able to trigger it? Admittedly I'm not familiar with Sanshiro's script or its alleged flaw, but my understanding of your code is that it is still setting the player's direction to one cardinal direction based on which buttons they had been pressing (and returning from the method before it can evaluate the other cases), and I feel like the player's intention may be one of any two directions they were pressing.
Hi, thank you!

Yes, it would still be able to trigger it!
I'm not sure if I understand you correctly, but I will give a try:

My intention was that there was a predominant direction in the player's movements.
Based on the first direction the player started walking.
So if he started walking down, he can walk (left || right) + down which will keep facing down.

The problem with the original plugin was that if it went down-left it would turn left(and not down).
But if he walked down-right it would turn down.
And all the other diagonal directions had this problem.
 

Wavelength

Pre-Merge Boot
Global Mod
Joined
Jul 22, 2014
Messages
4,698
Reaction score
3,960
First Language
English
Primarily Uses
RMVXA
Oh, I see now! So this wouldn't fix the scenario where a player started walking right and then turned up in order to reach the door, but it would fix it as long as they started walking up first, and it also stops the player's direction from turning like crazy while moving primarily in one direction, which is pretty nifty on its own.
 

bazrat

Pixel Game Maker MV
Veteran
Joined
Oct 15, 2018
Messages
238
Reaction score
167
First Language
English
Primarily Uses
Other
Awesome Eli, you figured it out xD

:MV1:
 

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,056
Reaction score
439
First Language
Portuguese - Br
Primarily Uses
RMMV
Updated to version 1.1!
- Fixed a problem with direction of the followers too.
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,285
Reaction score
431
First Language
Dutch
Primarily Uses
RMMV
@Eliaquim when checking your plugin, on "function fixNormalDir()" if player dir === 4, it doesn't have a return to 6,
while the other 3 (8, 6, 2) has a return, shouldn't 4 has a return as well? or do I miss something here?

EDIT:
there seems to be something off when look "left" or "right" and press both left and right and going doing, it look left or right and slide down.

but it doesn't happen when looking in other direction when pressing 3 buttons, while it go diagonal, It only happen when left, right and pressing down.

otherwise. nice plugin.
 
Last edited:

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,056
Reaction score
439
First Language
Portuguese - Br
Primarily Uses
RMMV
@Eliaquim when checking your plugin, on "function fixNormalDir()" if player dir === 4, it doesn't have a return to 6,
while the other 3 (8, 6, 2) has a return, shouldn't 4 has a return as well? or do I miss something here?

there seems to be something off when look "left" or "right" and press both left and right and going doing, it look left or right and slide down.

but it doesn't happen when looking in other direction when pressing 3 buttons, while it go diagonal, It only happen when left, right and pressing down.

otherwise. nice plugin.
Oh, thanks! I will check it out and give a reply here!

"function fixNormalDir()" if player dir === 4, it doesn't have a return to 6,
while the other 3 (8, 6, 2) has a return, shouldn't 4 has a return as well? or do I miss something here?
there seems to be something off when look "left" or "right" and press both left and right and going doing, it look left or right and slide down.
Fixed that! Thanks, ^^

but it doesn't happen when looking in other direction when pressing 3 buttons, while it go diagonal, It only happen when left, right and pressing down.
This is a very strange behavior. I realized that we can push three buttons at the same time.
But for each combination, the player performs a nonstandard movement, as you said.
Pressing down + right + up moves the player to the right looking down.
If you press left + right + up, the player moves up looking up.
But if we press down + left + right, the player continues to move diagonally.

1 - I made a few attempts and got a quick fix. With that, at least the player looks in the direction in which it is moving.

2 - Another fix I found is that pressing 3 directional at the same time will not move the player. It will be stopped until you release one of the buttons. I didn't find this beautiful, but at least it's a more standardized solution.

I will make more tests later and see what is the best option.

I hope Sanshiro notices my attempts and sympathizes with a mere mortal like me hahahaahaha.:hswt:

EDIT 3:
Well, it seems that this is behavior from the Core codes of Rm Mv itself.
I tried to remove both my fix plugin and the analog one, and the same thing happens, but not with diagonal. I can't find a way to solve this.
Rm Mv lets you press up-left-right.
But he doesn't let you press down-left-right
Put this at a parallel event and you will see.
Code:
◆If:Script:Input.isPressed("down") && Input.isPressed("right") && Input.isPressed("left")
  ◆Text:None, Window, Bottom
  :    :Player keep moving.
  ◆
:End
◆If:Script:Input.isPressed("up") && Input.isPressed("right") && Input.isPressed("left")
  ◆Text:None, Window, Bottom
  :    :Player stop moving.
  ◆
:End

So I will put the fix direction as a standard behavior in the plugin when you press those three buttons. At least the player will face the direction that he is walking.
But I will put a parameter that if it's set to true, the player will stop moving if these 3 directional buttons are pressed at the same time. If it's return false, the plugin will work with the standard behavior.

With that said:
Updated to version 1.2!
- Inserted plugin parameter as a workaround for another problem of direction
and movement with the player, when three directional buttons are pressed.
- Updated Help file.
 
Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,285
Reaction score
431
First Language
Dutch
Primarily Uses
RMMV
I test it out, but found the following (with param OFF)

when going left, down, right, it goes straight down)

when param ON (LOCK if player press 3 buttons)

up, left, right (lock player)
down + up, lock player, same for up + down

No lock when pressing left, up, down, up, left down, down, left, up,
which walk diagnoally to the left.

Idk how though, but I'm thinking, this wont be an easy fix,
while looking at teh code added, do you need to make any direction available to walk correctly
or make it lock, when left, down, up is pressed? or right, up, left, etc?

the lock work nicely when "right" is pressed though with 3 buttons pressed.
but while my coding isn't top yet, do you need && and || for button combinations? (just a guess though)

EDIT:
I might know a nice fix if you are able too.

for example:
if UP + LEFT is pressed, walk upper left (but if you press the 3rd button to it
like (RIGHT or DOWN) it will be ignored)

if UP + RIGHT is press, walk upper right (ignore the other 2)

and this on every direction, so 3 or 4 buttons cant be pressed and return
to the last 2 directions pressed.

Only if its possible though, so the lock param would be not needed anymore
and you have the prefect fix if you can accomplish it ^^.
 
Last edited:

Eliaquim

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,056
Reaction score
439
First Language
Portuguese - Br
Primarily Uses
RMMV
@ShadowDragon hi!
Thanks for giving it a try.
I'm already aware of these problems. But I can't solve it.
The best way to work around in this plugin is to have some way to detect the last input pressed before the current one.
But I can't do that(yet). So I made the plugin this way, with if statements to check the pressed buttons.
I can't make the character lock when, for example, press the 3 buttons: left, up, down. Because the Rm Mv doesn't let me press these 3 buttons at the same time(he don't recognize those three inputs).
Like I demonstrate here(if you put that in a parallel event, you will see):

Code:
◆If:Script:Input.isPressed("down") && Input.isPressed("right") && Input.isPressed("left")
  ◆Text:None, Window, Bottom
  :    :Player keep moving.
  ◆
:End
◆If:Script:Input.isPressed("up") && Input.isPressed("right") && Input.isPressed("left")
  ◆Text:None, Window, Bottom
  :    :Player stop moving.
  ◆
:End
Even if I figure a way out for this, it will mess with the default behavior of the Core codes from rm mv itself. And I don't wanna do that because it can create other problems with other plugins that I can't imagine. Also, I don't know if it is a bug from core codes, or it's a logic behind that which I don't understand xD.

So the only thing I do is at least, fix the direction of the player when all these buttons are pressed at the same time. And for those who think it is weird, if these buttons are pressed at the same time, it can lock the player.

Maybe in the future when my skills in coding are better, I can make a fix to it. But now, I can't.
Alternatively, if you want to use a pixel movement, you can try HalfMove.js from triacontanne. It's not pixel movement, but it is smooth ^^
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,285
Reaction score
431
First Language
Dutch
Primarily Uses
RMMV
I might use that in compare wit hthe other 2 plugins for behind objects and smooth stairs.
the setup for that is complicated but its awesome when done.

I try to find a way to fix this neet plugin, so only 2 buttons can reconized, and ignores the 3rd and 4th button press.
Or if you find out how. Than you have the nicest fix for this pixel movement.

Ping me if you got a way, or I ping you if I might have a way.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

buinguyenhoangtho wrote on fizzly's profile.
Hello @fizzly, i would like to use your asset/ resource for my project ( is maybe commercial ). May i have your permission? Thanks you !
I have 470+ hours on RMMV but have only made a demo game, is this normal? :kaoswt: (I lose motivation a lot plus I use a 32gb laptop, so..)
I like Iron Maiden.
Benku wrote on Magnus0808's profile.
Hey man you helped me out a long time ago with a plugin i was wondering if you can help me out one more time since its literally the last thing i need help with if not is cool but id figured id ask you one more soild.
Stream will be live shortly with a guest stream! Tonight, a new guest joins~ Feel free to drop by!

Forum statistics

Threads
95,425
Messages
929,067
Members
125,659
Latest member
gilgamegi
Top