MZ (Solved) Jitter on slow movement with parallax mapping

UPDATE: This is now solved!

A big thanks to @DrDhoom who responded to my commission request and whipped up a script to fix this in like 10 minutes, haha.

In their words:
"The problem isn't with the character object position itself, but with the character sprites. Unrounding the sprite position fixes the problem. Float value on the x and y is not a problem since Pixi can render it just fine. Also the reason why the parallax doesn't have the problem, because it already has floating x and y value."

They have given me permission to share their script here, so anyone else who wants to use diagonal movement without jittering can do so. Note that this is only tested with Galv's diagonal movement script, so I am not 100% sure if it would work with other diagonal movement scripts.

The fix plugin:
Spoiler: Plugin



Just add it after Galv's movement plugin and you're set.


Thanks to everyone that helped look into this!


Original post:
=============================================

Hey folks,

I have been having this head-scratching, frustrating issue for a while now, and I am hoping some RPG Maker wizard can help figure this out.

My game uses parallax mapping (Galv's plugin). It is using a 16x16 tileset, and it is zoomed in using a zoom plugin for a "big pixel" look.

The issue that I have is that, if I reduce the player movement speed to any value lower than the default (or exactly double the default), events on the map will "jitter", as they update slightly before the parallax map updates when I move.

This has caused me many problems. Any change to the movement speed causes this to occur, and most frustratingly, using any sort of diagonal movement or pixel movement necessitates slowing the character when moving diagonally (so that you don't travel twice as fast on the diagonal).
Because of this jitter, I can't run any diagonal movement plugins even though I really, really want to.

Here are video examples of what I mean:

Without diagonal speed reduction:



With 75% speed on diagonal movement:


I used to think the issue was just caused by diagonal movement in general (thinking it was some kind of rounding issue), but it is definitely caused by slowing the player speed. If I use a script to lower the player's movement speed, this same stuttering happens.

Turning off parallax mapping fixes this. The tilemap and the events update at the same time, so nothing falls out of sync. It is when parallax mapping is added to the mix that this starts happening, as I guess parallaxes that are snapped to the map update a frame or so later than the tilemap and events.

Using RPG Maker's default parallax mapping (setting a snapped parallax in the map settings) does not have this problem, so it is not a problem inherent to all parallaxes, just those managed by any plugin.
I would use the default parallax system, however I need 2 layers of parallax (top and bottom), so this doesn't work as a solution.

I am using both Galv's diagonal movement and parallax mapping plugins. Even though they are by the same author, they seem to have this strange incompatibility. I imagine it is less noticeable on a 48x48 game, but at this low res and zoomed in, the slight jitter is very jarring.

I have tried every diagonal movement and parallax plugin out there (as far as I can tell), and they have all had this same exact issue when combined.

I have messaged Galv and they said that while they do not have time to update the plugin, it may be something as simple as an error in their math. Hopefully it is!

For those who want to test, here is a demo project which highlights the issue clearly:
DOWNLOAD

Feel free to swap out any plugins for any others. All I want is to have 3x map zoom, diagonal movement (with 75% speed reduction on diagonal movement) and parallax mapping all in one game. I figure I surely must not be the first person to do this as these are super common features... yet here we are.

Thanks for your time!
Bumping since this was only just approved, but shows up as posted 2 days ago. (Hopefully this is allowed)
Just taking a look at the demo. At least I can confirm it has nothing to do with zooming. The jitter is still there without 3x zoom.
Just taking a look at the demo. At least I can confirm it has nothing to do with zooming. The jitter is still there without 3x zoom.

Yeah, that was my first suspect a while ago. I am certain I've seen games that have parallax mapping and diagonal movement, so I thought maybe it just worked for them because it was less noticeable on a 48x48 tileset.

But, no... I just have no clue what is happening at all.
Not at the computer at the moment but does Galv's Cam Control offer any help with the jitter?
I'm pretty sure it is because he forgot to round the numbers.
If I modify those 2 lines in GALV_LayerGraphicsMZ.js the jittering is gone. There could be other lines, but this should fix the static layers.

Though I think RM's original code is no better. Before the jittering is gone, the layers scroll much smoother. Now with the rounding, all things just jitter together.

1721577332947.png
I'm pretty sure it is because he forgot to round the numbers.
If I modify those 2 lines in GALV_LayerGraphicsMZ.js the jittering is gone. There could be other lines, but this should fix the static layers.

Though I think RM's original code is no better. Before the jittering is gone, the layers scroll much smoother. Now with the rounding, all things just jitter together.

View attachment 312088

Wow, that adds a lot of context to the problem....

It seems that Galv's un-rounded position updating is actually much smoother than the RM's updating math. This explains why the events jitter and the parallax layers don't... it's because the RM's position updating is rounded (and therefore jittery), while Galv's math is just smoother.

This makes the problem more complicated though... I think I need to find a way to make the RM update event position using the same math that Galv uses, if I'm not mistaken.

Not at the computer at the moment but does Galv's Cam Control offer any help with the jitter?

This was an interesting idea, but sadly it is a dead end. The first issue is that it doesn't seem to be compatible with VisuStella Core, which is a must for me. The other issue is that even with VS Core disabled, while this does actually stop the events and parallax layers from jittering independently from each other, it introduces the same "whole screen jitter" that the above fix introduces.


To further support this being an issue with the RM's updating math: when all plugins are disabled other than the diagonal movement plugin, and I set a parallax layer via the map settings in the RM, the same horrible jitter occurs. It seems that the RM + diafonal movement just = awful screen jitter for anything it is handling the updating for. The problem wasn't that Galv's plugins were causing jitter, but that the RM causes it and his plugin was fixing the math for everything except the events.

So... it seems that making the RM update event position with the same math as Galv's Layer Graphics, this should fix the jitter. Though.. I do not know how to do this.
:LZScheeze: I think you should go with this fix for now. The original code is not the best but at least it works. Changing them you need to watch out for potential bugs.
:LZScheeze: I think you should go with this fix for now. The original code is not the best but at least it works. Changing them you need to watch out for potential bugs.

Unfortunately, the jitter with this fix is extremely jarring, so I don't think I could use this fix. I would sooner just axe the diagonal movement.

I am playing around in the RM code for now, seeing if there is anything I can poke at that could fix it. the rmmz_sprites.js file seems to be where all of the position updating is happening, though so far tweaking any of the character sprite updating hasn't had any effect. I am just sort of blindly poking around in there.

I figure if I can find which bit handles the position updating for event sprites, I can maybe apply the same math as Galv's plugin so they line up and update smoothly. But, we'll see...

This appears to be the code for updating character sprite positions, though what to change, I do not know:

Spoiler: Code
Code:
//-----------------------------------------------------------------------------
// Sprite_Character
//
// The sprite for displaying a character.

function Sprite_Character() {
    this.initialize(...arguments);
}

Sprite_Character.prototype = Object.create(Sprite.prototype);
Sprite_Character.prototype.constructor = Sprite_Character;

Sprite_Character.prototype.initialize = function(character) {
    Sprite.prototype.initialize.call(this);
    this.initMembers();
    this.setCharacter(character);
};

Sprite_Character.prototype.initMembers = function() {
    this.anchor.x = 0.5;
    this.anchor.y = 1;
    this._character = null;
    this._balloonDuration = 0;
    this._tilesetId = 0;
    this._upperBody = null;
    this._lowerBody = null;
};

Sprite_Character.prototype.setCharacter = function(character) {
    this._character = character;
};

Sprite_Character.prototype.checkCharacter = function(character) {
    return this._character === character;
};

Sprite_Character.prototype.update = function() {
    Sprite.prototype.update.call(this);
    this.updateBitmap();
    this.updateFrame();
    this.updatePosition();
    this.updateOther();
    this.updateVisibility();
};

Sprite_Character.prototype.updateVisibility = function() {
    Sprite.prototype.updateVisibility.call(this);
    if (this.isEmptyCharacter() || this._character.isTransparent()) {
        this.visible = false;
    }
};

Sprite_Character.prototype.isTile = function() {
    return this._character.isTile();
};

Sprite_Character.prototype.isObjectCharacter = function() {
    return this._character.isObjectCharacter();
};

Sprite_Character.prototype.isEmptyCharacter = function() {
    return this._tileId === 0 && !this._characterName;
};

Sprite_Character.prototype.tilesetBitmap = function(tileId) {
    const tileset = $gameMap.tileset();
    const setNumber = 5 + Math.floor(tileId / 256);
    return ImageManager.loadTileset(tileset.tilesetNames[setNumber]);
};

Sprite_Character.prototype.updateBitmap = function() {
    if (this.isImageChanged()) {
        this._tilesetId = $gameMap.tilesetId();
        this._tileId = this._character.tileId();
        this._characterName = this._character.characterName();
        this._characterIndex = this._character.characterIndex();
        if (this._tileId > 0) {
            this.setTileBitmap();
        } else {
            this.setCharacterBitmap();
        }
    }
};

Sprite_Character.prototype.isImageChanged = function() {
    return (
        this._tilesetId !== $gameMap.tilesetId() ||
        this._tileId !== this._character.tileId() ||
        this._characterName !== this._character.characterName() ||
        this._characterIndex !== this._character.characterIndex()
    );
};

Sprite_Character.prototype.setTileBitmap = function() {
    this.bitmap = this.tilesetBitmap(this._tileId);
};

Sprite_Character.prototype.setCharacterBitmap = function() {
    this.bitmap = ImageManager.loadCharacter(this._characterName);
    this._isBigCharacter = ImageManager.isBigCharacter(this._characterName);
};

Sprite_Character.prototype.updateFrame = function() {
    if (this._tileId > 0) {
        this.updateTileFrame();
    } else {
        this.updateCharacterFrame();
    }
};



Sprite_Character.prototype.updateCharacterFrame = function() {
    const pw = this.patternWidth();
    const ph = this.patternHeight();
    const sx = (this.characterBlockX() + this.characterPatternX()) * pw;
    const sy = (this.characterBlockY() + this.characterPatternY()) * ph;
    this.updateHalfBodySprites();
    if (this._bushDepth > 0) {
        const d = this._bushDepth;
        this._upperBody.setFrame(sx, sy, pw, ph - d);
        this._lowerBody.setFrame(sx, sy + ph - d, pw, d);
        this.setFrame(sx, sy, 0, ph);
    } else {
        this.setFrame(sx, sy, pw, ph);
    }
};

Sprite_Character.prototype.characterBlockX = function() {
    if (this._isBigCharacter) {
        return 0;
    } else {
        const index = this._character.characterIndex();
        return (index % 4) * 3;
    }
};

Sprite_Character.prototype.characterBlockY = function() {
    if (this._isBigCharacter) {
        return 0;
    } else {
        const index = this._character.characterIndex();
        return Math.floor(index / 4) * 4;
    }
};

Sprite_Character.prototype.characterPatternX = function() {
    return this._character.pattern();
};

Sprite_Character.prototype.characterPatternY = function() {
    return (this._character.direction() - 2) / 2;
};

Sprite_Character.prototype.patternWidth = function() {
    if (this._tileId > 0) {
        return $gameMap.tileWidth();
    } else if (this._isBigCharacter) {
        return this.bitmap.width / 3;
    } else {
        return this.bitmap.width / 12;
    }
};

Sprite_Character.prototype.patternHeight = function() {
    if (this._tileId > 0) {
        return $gameMap.tileHeight();
    } else if (this._isBigCharacter) {
        return this.bitmap.height / 4;
    } else {
        return this.bitmap.height / 8;
    }
};

Sprite_Character.prototype.updateHalfBodySprites = function() {
    if (this._bushDepth > 0) {
        this.createHalfBodySprites();
        this._upperBody.bitmap = this.bitmap;
        this._upperBody.visible = true;
        this._upperBody.y = -this._bushDepth;
        this._lowerBody.bitmap = this.bitmap;
        this._lowerBody.visible = true;
        this._upperBody.setBlendColor(this.getBlendColor());
        this._lowerBody.setBlendColor(this.getBlendColor());
        this._upperBody.setColorTone(this.getColorTone());
        this._lowerBody.setColorTone(this.getColorTone());
        this._upperBody.blendMode = this.blendMode;
        this._lowerBody.blendMode = this.blendMode;
    } else if (this._upperBody) {
        this._upperBody.visible = false;
        this._lowerBody.visible = false;
    }
};

Sprite_Character.prototype.createHalfBodySprites = function() {
    if (!this._upperBody) {
        this._upperBody = new Sprite();
        this._upperBody.anchor.x = 0.5;
        this._upperBody.anchor.y = 1;
        this.addChild(this._upperBody);
    }
    if (!this._lowerBody) {
        this._lowerBody = new Sprite();
        this._lowerBody.anchor.x = 0.5;
        this._lowerBody.anchor.y = 1;
        this._lowerBody.opacity = 128;
        this.addChild(this._lowerBody);
    }
};

Sprite_Character.prototype.updatePosition = function() {
    this.x = this._character.screenX();
    this.y = this._character.screenY();
    this.z = this._character.screenZ();
};

Sprite_Character.prototype.updateOther = function() {
    this.opacity = this._character.opacity();
    this.blendMode = this._character.blendMode();
    this._bushDepth = this._character.bushDepth();
};
Hi there!

I took a look at the Demo, and as far as I could understand, the "problem" is on the calculations of the method .distancePerFrame that is on the Game_Character( or Game_CharacterBase). This method plays a crucial role on the screen scrolling/camera when the player is moving.

It seems to me that this method is not, let's say, compatible, with a character speed that is not an integer (like 3.5 speed for example).

The default player speed is 4, if the diagonal speed of the player is 75% of it's normal speed, it will be 3.something.

Tested with Galv and also my Diagonal plugin. Although, my diagonal plugin does not work with %, but with a number to represent the speed. So, I could always put the diagonal speed = Player Speed - 1.

So Whatever speed I changed for the player, the jitter did not happen. The problem is, that -1 to the player speed when moving diagonally is too much, and the movement on diagonal stays much slower than the regular direction movement.

Understood that, I believe, we would need to find a calculation for the distance per frame that would be friendly with decimal numbers.

Or set the diagonal speed to be the same as the regular movement speed or -1.

( I also did try a lot of other things, like rounding the calculations number like someone said above. Update the characters positions, parallax position and map display positions all together, but none of that seems to solve the issue).
Hi there!

I took a look at the Demo, and as far as I could understand, the "problem" is on the calculations of the method .distancePerFrame that is on the Game_Character( or Game_CharacterBase). This method plays a crucial role on the screen scrolling/camera when the player is moving.

It seems to me that this method is not, let's say, compatible, with a character speed that is not an integer (like 3.5 speed for example).

The default player speed is 4, if the diagonal speed of the player is 75% of it's normal speed, it will be 3.something.

Tested with Galv and also my Diagonal plugin. Although, my diagonal plugin does not work with %, but with a number to represent the speed. So, I could always put the diagonal speed = Player Speed - 1.

So Whatever speed I changed for the player, the jitter did not happen. The problem is, that -1 to the player speed when moving diagonally is too much, and the movement on diagonal stays much slower than the regular direction movement.

Understood that, I believe, we would need to find a calculation for the distance per frame that would be friendly with decimal numbers.

Or set the diagonal speed to be the same as the regular movement speed or -1.

( I also did try a lot of other things, like rounding the calculations number like someone said above. Update the characters positions, parallax position and map display positions all together, but none of that seems to solve the issue).

Thanks for taking a look at it!

My only hope seems to be that, somehow, Galv's Layer Graphics plugin doesn't have this need for a "full" number when updating the position of the parallax layer sprite, so there must be some way to do the same for character sprites (hopefully!).

Do you think it is possible to somehow apply the same sort of math that is being used in Galv's plugin to the .distancePerFrame method? Somehow, Galv doesn't seem to need whole numbers for the layer sprites (they are buttery smooth even at, say, 3.5 speed). I imagine this is due to his calculations being different than how the RM handles them.

This seems to be his sprite drawing/position updating code, though I am not sure how to take any math from it and apply it to the RM (I know nothing about JS really):

Spoiler: CODE
JavaScript:
// CREATE STATIC LAYER SPRITE
//-----------------------------------------------------------------------------
function Sprite_LayerGraphicS(id) {
    this.id = id;
    this.initialize(...arguments);
}

Sprite_LayerGraphicS.prototype = Object.create(Sprite.prototype);
Sprite_LayerGraphicS.prototype.constructor = Sprite_LayerGraphicS;

Sprite_LayerGraphicS.prototype.initialize = function() {
    Sprite.prototype.initialize.call(this);
    this._rVals = [
                0,            // Can't have direction 0
                0.785398,    // 45 degrees
                0,            // 0 degrees
                5.49779,    // 315 degrees
                1.5708,        // 90 degrees
                0,            // Can't have direction 5
                4.71239,    // 270 degrees
                2.35619,    // 135 degrees
                3.14159,    // 180 degrees
                3.92699        // 225 degrees
            ];
    
    this._tileSize = $gameMap.tileWidth();
    this.currentGraphic = "";
    this.createBitmap();
    this.update();
};

Sprite_LayerGraphicS.prototype.createBitmap = function(val) {
    val = val || this.lValue();
    if (Galv.LG.isEmpty($gameMap.layerConfig()[this.id])) {
        this.bitmap = ImageManager.loadLayerGraphic("");
    } else {
        this.bitmap = ImageManager.loadLayerGraphic(val.graphic);
    };
    this.z = val.z;
};

Sprite_LayerGraphicS.prototype.lValue = function() {
    return $gameMap.layerConfig()[this.id];
};

// Update
Sprite_LayerGraphicS.prototype.update = function() {
    Sprite.prototype.update.call(this);
    let val = this.lValue();
    if (this.currentGraphic !== val.graphic) {
        this.createBitmap(val);
        this.currentGraphic = val.graphic;
    };
    this.updatePosition(val);
};

// Update Position
Sprite_LayerGraphicS.prototype.updatePosition = function(val) {   
    this.z = val.z || 0;
    this.opacity = val.opacity || 0;
    this.blendMode = val.blend || 0;
    
    if (val.character) {
        // get character object
        let char = val.character > 0 ? $gameMap.event(val.character) : $gamePlayer;
        
        // set x,y to character's x,y
        let center = this._tileSize / 2;
        let tx = char._realX * this._tileSize + center;
        let ty = char._realY * this._tileSize + center;
        this.x = tx - $gameMap.displayX() * this._tileSize;
        this.y = ty - $gameMap.displayY() * this._tileSize;
        
        // rotate
        if (val.rotate) {
            this.rotation = this._rVals[char._direction];
        } else {
            this.rotation = 0;
        }   
    } else {
        this.x = val.x - $gameMap.displayX() * this._tileSize;
        this.y = val.y - $gameMap.displayY() * this._tileSize;
        this.rotation = 0;
    }
    this.anchor.x = val.xa;
    this.anchor.y = val.ya;
};
Yeah when you are using zoom 3x, it means everything moves at least 3 pixels per frame. But without the rounding, the layers can move 1 pixel, so it looks smoother. That is my understanding.
Yeah when you are using zoom 3x, it means everything moves at least 3 pixels per frame. But without the rounding, the layers can move 1 pixel, so it looks smoother. That is my understanding.

I really couldn't say myself! Something to consider for sure.

Either way, it seems that "unlocking" the character sprite updating method by allowing it to update with whatever math Galv has used rather than rounding seems to be the way to go.
Thanks for taking a look at it!

My only hope seems to be that, somehow, Galv's Layer Graphics plugin doesn't have this need for a "full" number when updating the position of the parallax layer sprite, so there must be some way to do the same for character sprites (hopefully!).

Do you think it is possible to somehow apply the same sort of math that is being used in Galv's plugin to the .distancePerFrame method? Somehow, Galv doesn't seem to need whole numbers for the layer sprites (they are buttery smooth even at, say, 3.5 speed). I imagine this is due to his calculations being different than how the RM handles them.

This seems to be his sprite drawing/position updating code, though I am not sure how to take any math from it and apply it to the RM (I know nothing about JS really):

Spoiler: CODE
JavaScript:
// CREATE STATIC LAYER SPRITE
//-----------------------------------------------------------------------------
function Sprite_LayerGraphicS(id) {
    this.id = id;
    this.initialize(...arguments);
}

Sprite_LayerGraphicS.prototype = Object.create(Sprite.prototype);
Sprite_LayerGraphicS.prototype.constructor = Sprite_LayerGraphicS;

Sprite_LayerGraphicS.prototype.initialize = function() {
    Sprite.prototype.initialize.call(this);
    this._rVals = [
                0,            // Can't have direction 0
                0.785398,    // 45 degrees
                0,            // 0 degrees
                5.49779,    // 315 degrees
                1.5708,        // 90 degrees
                0,            // Can't have direction 5
                4.71239,    // 270 degrees
                2.35619,    // 135 degrees
                3.14159,    // 180 degrees
                3.92699        // 225 degrees
            ];
   
    this._tileSize = $gameMap.tileWidth();
    this.currentGraphic = "";
    this.createBitmap();
    this.update();
};

Sprite_LayerGraphicS.prototype.createBitmap = function(val) {
    val = val || this.lValue();
    if (Galv.LG.isEmpty($gameMap.layerConfig()[this.id])) {
        this.bitmap = ImageManager.loadLayerGraphic("");
    } else {
        this.bitmap = ImageManager.loadLayerGraphic(val.graphic);
    };
    this.z = val.z;
};

Sprite_LayerGraphicS.prototype.lValue = function() {
    return $gameMap.layerConfig()[this.id];
};

// Update
Sprite_LayerGraphicS.prototype.update = function() {
    Sprite.prototype.update.call(this);
    let val = this.lValue();
    if (this.currentGraphic !== val.graphic) {
        this.createBitmap(val);
        this.currentGraphic = val.graphic;
    };
    this.updatePosition(val);
};

// Update Position
Sprite_LayerGraphicS.prototype.updatePosition = function(val) {  
    this.z = val.z || 0;
    this.opacity = val.opacity || 0;
    this.blendMode = val.blend || 0;
   
    if (val.character) {
        // get character object
        let char = val.character > 0 ? $gameMap.event(val.character) : $gamePlayer;
       
        // set x,y to character's x,y
        let center = this._tileSize / 2;
        let tx = char._realX * this._tileSize + center;
        let ty = char._realY * this._tileSize + center;
        this.x = tx - $gameMap.displayX() * this._tileSize;
        this.y = ty - $gameMap.displayY() * this._tileSize;
       
        // rotate
        if (val.rotate) {
            this.rotation = this._rVals[char._direction];
        } else {
            this.rotation = 0;
        }  
    } else {
        this.x = val.x - $gameMap.displayX() * this._tileSize;
        this.y = val.y - $gameMap.displayY() * this._tileSize;
        this.rotation = 0;
    }
    this.anchor.x = val.xa;
    this.anchor.y = val.ya;
};
I don't think that is the point here. The way the characters and galv layers update their positions, on my understanding has nothing to do with the jitter issue.

I believe the issue is on the distancePerFrame method calculations that are also tied to how the map scrolls when the player moves.

I did try to play with it a little bit, but although I know what the calculation does, I don't know why it needs to be done like that.
When I created my Camera Plugin, I messed a lot with it at first. And ended going with a different approach.

On another words, I don't know how to fix this, but I believe the problem lies there. If you remove all plugins, and leave only the diagonal one, with a diagonal speed that has decimals, the problem is still there. That's why I don't believe the way Galv Layer calculate things is the solution.

Well, since I don't know how to fix, I can also be wrong hahaha
But as far as I understood it, that is the problem. Because even if you walk on a regular direction(not diagonally) with a speed like 3.5 the jitter will happen anyway.
@Eliaquim Actually, it is the layers that don't keep with the rest of the sprites. Like it is showed in my screenshot above, changing those 2 lines fix the problem. At least it works like when you use a normal tileset.
So now the OP is talking about the original scrolling method is not as smooth as he expected.
@Eliaquim Actually, it is the layers that don't keep with the rest of the sprites. Like it is showed in my screenshot above, changing those 2 lines fix the problem. At least it works like when you use a normal tileset.
So now the OP is talking about the original scrolling method is not as smooth as he expected.
I tested it here again, but I had tested it before using Math.round. Either way, this did not fix the jittering issue, at least on my eyes. It does make it less noticible, but it is still there. If you walk into a regular direction, and walk using the diagonal direction, you can see the difference. For me, it should look just the same on any direction, but it is not.


I agree with you, that maybe, the OP should go with that fix anyway. But I really don't know if on other situations(Player moving with different speed, Map scroll event commands, events also moving on screen), this fix will behave the same.

--------------
These are the methods I talked about:
JavaScript:
Game_CharacterBase.prototype.distancePerFrame = function() {
    return Math.pow(2, this.realMoveSpeed()) / 256;
};

Game_CharacterBase.prototype.realMoveSpeed = function() {
    return this._moveSpeed + (this.isDashing() ? 1 : 0);
};

If you do a console log, replacing the realMoveSpeed from 1 to 6(Minimum default speed to max default speed), you will get the following results:
1721615334300.png

But as soon as you change that to a decimal number, the numbers go "crazy":
1721615405459.png


So, if you "follow" the code, you can see how this result affects the map display and parallax position:
JavaScript:
Game_CharacterBase.prototype.updateMove = function() {
    if (this._x < this._realX) {
        this._realX = Math.max(this._realX - this.distancePerFrame(), this._x);
    }
    if (this._x > this._realX) {
        this._realX = Math.min(this._realX + this.distancePerFrame(), this._x);
    }
    if (this._y < this._realY) {
        this._realY = Math.max(this._realY - this.distancePerFrame(), this._y);
    }
    if (this._y > this._realY) {
        this._realY = Math.min(this._realY + this.distancePerFrame(), this._y);
    }
    if (!this.isMoving()) {
        this.refreshBushDepth();
    }
};

Game_CharacterBase.prototype.scrolledX = function() {
    return $gameMap.adjustX(this._realX);
};

Game_CharacterBase.prototype.scrolledY = function() {
    return $gameMap.adjustY(this._realY);
};

Game_Player.prototype.update = function(sceneActive) {
    const lastScrolledX = this.scrolledX();
    const lastScrolledY = this.scrolledY();
    const wasMoving = this.isMoving();
    this.updateDashing();
    if (sceneActive) {
        this.moveByInput();
    }
    Game_Character.prototype.update.call(this);
    this.updateScroll(lastScrolledX, lastScrolledY);
    this.updateVehicle();
    if (!this.isMoving()) {
        this.updateNonmoving(wasMoving, sceneActive);
    }
    this._followers.update();
};

Game_Player.prototype.updateScroll = function(lastScrolledX, lastScrolledY) {
    const x1 = lastScrolledX;
    const y1 = lastScrolledY;
    const x2 = this.scrolledX();
    const y2 = this.scrolledY();
    if (y2 > y1 && y2 > this.centerY()) {
        $gameMap.scrollDown(y2 - y1);
    }
    if (x2 < x1 && x2 < this.centerX()) {
        $gameMap.scrollLeft(x1 - x2);
    }
    if (x2 > x1 && x2 > this.centerX()) {
        $gameMap.scrollRight(x2 - x1);
    }
    if (y2 < y1 && y2 < this.centerY()) {
        $gameMap.scrollUp(y1 - y2);
    }
};

The map scroll methods receive as an argument a distance. And when the player moves with a decimal speed, the distance turns out to be a value that is not precise as it was before, which makes the game map scroll "funny", without the precision it does when the player has an integer value as their move speed.

That is why if, even if you disable all plugins, including diagonal ones, with just the default maker running, the problem is still there, if, the player has a decimal move speed. Tested trhis using the diagonal movement with the move route. The jittering effect is lower, and somehow different, but it still does not scroll smoothly as it suppose to be.
I tested it here again, but I had tested it before using Math.round. Either way, this did not fix the jittering issue, at least on my eyes. It does make it less noticible, but it is still there. If you walk into a regular direction, and walk using the diagonal direction, you can see the difference. For me, it should look just the same on any direction, but it is not.


I agree with you, that maybe, the OP should go with that fix anyway. But I really don't know if on other situations(Player moving with different speed, Map scroll event commands, events also moving on screen), this fix will behave the same.

--------------
These are the methods I talked about:
JavaScript:
Game_CharacterBase.prototype.distancePerFrame = function() {
    return Math.pow(2, this.realMoveSpeed()) / 256;
};

Game_CharacterBase.prototype.realMoveSpeed = function() {
    return this._moveSpeed + (this.isDashing() ? 1 : 0);
};

If you do a console log, replacing the realMoveSpeed from 1 to 6(Minimum default speed to max default speed), you will get the following results:
View attachment 312116
But as soon as you change that to a decimal number, the numbers go "crazy":
View attachment 312117

So, if you "follow" the code, you can see how this result affects the map display and parallax position:
JavaScript:
Game_CharacterBase.prototype.updateMove = function() {
    if (this._x < this._realX) {
        this._realX = Math.max(this._realX - this.distancePerFrame(), this._x);
    }
    if (this._x > this._realX) {
        this._realX = Math.min(this._realX + this.distancePerFrame(), this._x);
    }
    if (this._y < this._realY) {
        this._realY = Math.max(this._realY - this.distancePerFrame(), this._y);
    }
    if (this._y > this._realY) {
        this._realY = Math.min(this._realY + this.distancePerFrame(), this._y);
    }
    if (!this.isMoving()) {
        this.refreshBushDepth();
    }
};

Game_CharacterBase.prototype.scrolledX = function() {
    return $gameMap.adjustX(this._realX);
};

Game_CharacterBase.prototype.scrolledY = function() {
    return $gameMap.adjustY(this._realY);
};

Game_Player.prototype.update = function(sceneActive) {
    const lastScrolledX = this.scrolledX();
    const lastScrolledY = this.scrolledY();
    const wasMoving = this.isMoving();
    this.updateDashing();
    if (sceneActive) {
        this.moveByInput();
    }
    Game_Character.prototype.update.call(this);
    this.updateScroll(lastScrolledX, lastScrolledY);
    this.updateVehicle();
    if (!this.isMoving()) {
        this.updateNonmoving(wasMoving, sceneActive);
    }
    this._followers.update();
};

Game_Player.prototype.updateScroll = function(lastScrolledX, lastScrolledY) {
    const x1 = lastScrolledX;
    const y1 = lastScrolledY;
    const x2 = this.scrolledX();
    const y2 = this.scrolledY();
    if (y2 > y1 && y2 > this.centerY()) {
        $gameMap.scrollDown(y2 - y1);
    }
    if (x2 < x1 && x2 < this.centerX()) {
        $gameMap.scrollLeft(x1 - x2);
    }
    if (x2 > x1 && x2 > this.centerX()) {
        $gameMap.scrollRight(x2 - x1);
    }
    if (y2 < y1 && y2 < this.centerY()) {
        $gameMap.scrollUp(y1 - y2);
    }
};

The map scroll methods receive as an argument a distance. And when the player moves with a decimal speed, the distance turns out to be a value that is not precise as it was before, which makes the game map scroll "funny", without the precision it does when the player has an integer value as their move speed.

That is why if, even if you disable all plugins, including diagonal ones, with just the default maker running, the problem is still there, if, the player has a decimal move speed. Tested trhis using the diagonal movement with the move route. The jittering effect is lower, and somehow different, but it still does not scroll smoothly as it suppose to be.


Wow, thanks for all this testing!

I feel that the question remains: if the RM works like this and looks jittery, how on earth did Galv get his parallax sprites to scroll so differently? It seems like he must have his own entire process for updating the position that can handle decimals better, otherwise you'd see the same kind of jitter on his sprites. On maps with no events and just his parallax map, everything looks as it should when moving diagonal.

I don't know much about code, but the RM almost looks to me like it is "stepping" up then left by 1 px per frame each, whereas Galv's sprites are skipping the "up" and then moving "up+left" all at once, so it looks diagonal.
Sorry for the double-post, but I wanted to bump this with one last post as this is now SOLVED!

A big thanks to @DrDhoom who responded to my commission request and whipped up a script to fix this in like 10 minutes, haha.

In their words:
"The problem isn't with the character object position itself, but with the character sprites. Unrounding the sprite position fixes the problem. Float value on the x and y is not a problem since Pixi can render it just fine. Also the reason why the parallax doesn't have the problem, because it already has floating x and y value."

They have given me permission to share their script here, so anyone else who wants to use diagonal movement without jittering can do so. Note that this is only tested with Galv's diagonal movement script, so I am not 100% sure if it would work with other diagonal movement scripts.

The fix plugin:


Just add it after Galv's movement plugin and you're set.


Thanks to everyone that helped look into this!
I would never though about that hahaha
I tested here and it worked just fine!

Original thread: https://forums.rpgmakerweb.com/threads/solved-jitter-on-slow-movement-with-parallax-mapping.170456/