• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [Solved] Stop jittery movement when view is centered on an object

T

tamation

Guest
Hey everyone.

I've got a character moving at a speed of 1.5, not ideal, I know, but the closest rounded numbers of 1 & 2 are either too slow or too fast for this game's resolution (256x144).

The view is centered on that player, but the issue is whenever the screen starts moving the player will begin to shake.

Is there any way of smoothing this out without needing to change the variable? I've tried using floor and round but they haven't improved it.
 

JasonTomLee

Member
Try lerping the values, whether it be the player's position or the view's position!
I'd do it something like this:

Code:
// Center view based on player position
view_x  = oPlayer.x- ( view_w/2 );
view_y = oPlayer.y- ( view_h/2 );

// Center view using lerp
var set_x = oPlayer.x- ( view_w/2 );
var set_y = oPlayer.y- ( view_h/2 );

view_x = lerp( view_x, set_x, 0.1 );
view_y = lerp( view_y, set_y, 0.1 );
 

Ido-f

Member
I don't believe that the camera would be jittery just because of the small resolution used.
Gamemaker actually keeps the "sub-pixels" and they're used as the view (the area the camera is shooting) is scaled into the view port (the actual screen space used to display the game).

I've had an issue similar to yours once, probably because of the same reasons.
The movement would display noticeable jitter but only for those low speed values.
It happened because I've built everything around maintaining integer positions, based on youtube advice.
Removing those integer maintainment methods fixed it.
Besides some solvable issues with tile collisions, removing int positions didn't cause any further problems.

If that's not your case, I suggest you submit your camera and your movements codes here so we might be able to help.
 
Top