How to make the player not change direction during movement?

How can I make the player not change its direction during movement by input?

I'm trying to change a bit the way MV works, making the player always look at the mouse position, but whenever I press a key to move, it quickly turns to the direction of the movement then back at the mouse position.
Move Route -> for Player -> Direction Fix ON makes it unable to change direction, Direction Fix OFF turns it off.

Edit: Oh, sorry...By input, you mean on keyboard? Sorry for offtopic -_-
Edit: Oh, sorry...By input, you mean on keyboard? Sorry for offtopic -_-
yea thats what I meant. I wanted a script that would disable the direction change during movement when the player press a movement key
An input-induced move invokes Game_Player.prototype.executeMove, which by default just calls moveStraight. So a simple solution would be to just copy+paste Game_CharacterBase.prototype.moveStraight, remove the setDirection lines, and set that up as an override for executeMove. However, with that approach you'd need to be careful about plugins you may be using that affect the moveStraight code... 😅

Suggestion: have a flag that flips whenever executeMove is called, which disables setDirection for that move. I've written a little plugin that seems to do this: the player doesn't turn unless they're undergoing a forced move (i.e. move route). Might need adjustment based on what movement plugins you may be using, though. Plugin attached (you can rename it if you like), full code in spoiler below~
Spoiler: Full code
Code:
(function() {
'use strict';

	let noTurn;

	(function(alias) {
		Game_Player.prototype.executeMove = function(d) {
			noTurn = true;
			alias.call(this, d);
		};
	})(Game_Player.prototype.executeMove);

	(function(alias) {
		Game_Player.prototype.setDirection = function(d) {
			if (!noTurn) alias.call(this, d);
			else noTurn = false;
		};
	})(Game_Player.prototype.setDirection);

})();
[Edit: removed redundant alias.]
An input-induced move invokes Game_Player.prototype.executeMove, which by default just calls moveStraight. So a simple solution would be to just copy+paste Game_CharacterBase.prototype.moveStraight, remove the setDirection lines, and set that up as an override for executeMove. However, with that approach you'd need to be careful about plugins you may be using that affect the moveStraight code... 😅

Suggestion: have a flag that flips whenever executeMove is called, which disables setDirection for that move. I've written a little plugin that seems to do this: the player doesn't turn unless they're undergoing a forced move (i.e. move route). Might need adjustment based on what movement plugins you may be using, though. Plugin attached (you can rename it if you like), full code in spoiler below~
Spoiler: Full code
Code:
(function() {
'use strict';

    let noTurn;

    (function(alias) {
        Game_Player.prototype.executeMove = function(d) {
            noTurn = true;
            alias.call(this, d);
        };
    })(Game_Player.prototype.executeMove);

    (function(alias) {
        Game_Player.prototype.setDirection = function(d) {
            if (!noTurn) alias.call(this, d);
            else noTurn = false;
        };
    })(Game_Player.prototype.setDirection);

})();
[Edit: removed redundant alias.]
seems to work perfectly! Thank you!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-the-player-not-change-direction-during-movement.114421/