A little lag when the screen is scrolling

Started by DiegoHolt, Tue 01/10/2024 17:52:59

Previous topic - Next topic

DiegoHolt

Hello, beautiful community.

I'm having a debate with a friend here, and he's starting to convince me.

The thing is the scrolling, he says there is a little lag (I don't know what to call it, and 'lag' seems to be fair enough) when the screen scrolls. I didn't notice it before, but now I can't unseen it.

Is this normal? Maybe I needed to change something like the FPS when changing the game's resolution?


Thanks for your time!  :)

ThreeOhFour

It's definitely not as smooth as it could be. Have you tried using the Tween module to move the camera? What command are you using to move the screen?

AndreasBlack

set the framerate to 60fps or higher. I think AGS standard is 40, unless they've changed it. See if that helps

Khris

#3
Looks like you're using the player character for this. Walking characters usually do not move smooth because they do not have dozens of walkcycle frames and therefore will move a bunch of pixels every few frames. This will give a choppy result, which is why there are a bunch of modules that take care of this.
There's even a smooth scrolling module written specifically to address this very common issue: https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-smooth-scrolling-parallax-v1-7-1/

Danvzare

  • Select the player character in the editor, and look at the list of options to the side.
  • There should be one option that says "MovementLinkedToAnimation", set it to "False".
  • Enjoy your smooth scrolling screen.

It's an option that's set to true by default because it makes walking animations look decent with zero effort on the part of the artist or programmer.
But the cost can be jerky movement that is enough to give someone motion sickness in my opinion.

eri0o

#5
I have a script somewhere where I have a config so that if the screen can't move it uses Movement linked to animation and if can move it doesn't - by setting the property to false through script. I also use two frames per image when using Movement linked to animation, so it can "fake slide" something that looks like a half frame and this allows me using a small pixel distance per step, which is the main thing that causes choppiness.

In this particular scene shown in the video though, it looks like a simple camera tween would be the easy way to have it smooth - along with making sure you have SetGameSpeed(60) at game_start.

Crimson Wizard

#6
It's unfortunate that no code is posted, and I dislike guessing.

But since this was not mentioned in the replies above: if you are scrolling camera yourself in script, and target some character's or object's position, then make certain that it's done in "late_repeatedly_execute_always", this way it will be done *after* character moves.

Snarky

#7
Quote from: Danvzare on Wed 02/10/2024 12:38:55
  • Select the player character in the editor, and look at the list of options to the side.
  • There should be one option that says "MovementLinkedToAnimation", set it to "False".
  • Enjoy your smooth scrolling screen.

It's an option that's set to true by default because it makes walking animations look decent with zero effort on the part of the artist or programmer.
But the cost can be jerky movement that is enough to give someone motion sickness in my opinion.

I strongly disagree with this advice.

If you turn off "Movement linked to animation" you get a gliding effect when walking, since the character moves even when the animation frame doesn't change, making the feet slide across the ground. This looks very bad, and is a bigger issue than the scrolling, which can anyway be fixed in other ways.

And in this case it shouldn't have anything to do with the issue at all, since there is no walking character on the screen. The original poster must be doing something in a non-optimal way.

eri0o

Right, the code for tween is something like

Code: ags
Game.Camera.TweenPosition(1.0 /*seconds*/, 1200 /*X*/, 0/*Y*/, eEaseLinear, eTweenBlock);

More info in the module docs https://edmundito.gitbook.io/ags-tween/basic/screen

Danvzare

Quote from: Snarky on Wed 02/10/2024 16:04:04If you turn off "Movement linked to animation" you get a gliding effect when walking
Only when you set things up wrong.
But why take my word for it, when I can just provide a series of gifs.

This is what you get with MovementLinkedToAnimation is set to true, and it's set correctly:


This is what you get with MovementLinkedToAnimation is set to true, and it's set wrong:


This is what you get with MovementLinkedToAnimation is set to false, and it's set correctly:


This is what you get with MovementLinkedToAnimation is set to false, and it's set wrong:



As you can clearly see, setting it to false not only gives a much smoother scrolling effect and less choppy character movement, but when the character animation delay and speed are set correctly, it even removes the gliding effect that people like Snarky think MovementLinkedToAnimation is required to fix.

Crimson Wizard

#10
Quote from: Danvzare on Thu 03/10/2024 11:31:50As you can clearly see, setting it to false not only gives a much smoother scrolling effect

That is because camera is made to follow the character's position exactly in AGS by default, but that's not the perfect solution.
I suppose that If camera were scripted to move with the average character speed instead, then it would not depend on MovementLinkedToAnimation at all; as it should be.

EDIT: unfortunately, it may not be trivial to do in script in case of randomly walking character, as character "velocity" (or movement direction) is not exposed to script at the moment. The script would have to keep track on character positions and do projection.

Snarky

Quote from: Danvzare on Thu 03/10/2024 11:31:50This is what you get with MovementLinkedToAnimation is set to false, and it's set correctly:


As you can clearly see, setting it to false not only gives a much smoother scrolling effect and less choppy character movement, but when the character animation delay and speed are set correctly, it even removes the gliding effect that people like Snarky think MovementLinkedToAnimation is required to fix.

Do you not see the feet gliding in this gif? He's practically moonwalking!

ThreeOhFour

Danvzare, it can be a little hard to see these things if you're not looking close enough, but it might be worth slowing your gifs down and zooming in and taking a closer look. This is how your "goodnonlinked.gif" example appears when you do that:


Danvzare

I suppose we'll just have to agree to disagree.  (nod)

I prefer the way the vast majority of 2D games handle walk cycles.
And you prefer the way old PC games handled walk cycles.

We're both biased in our preferences. And if you believe otherwise, try showing the goodnonlinked and goodlinked gifs to any non-adventure game fan and simply ask which they prefer (without explaining what the difference is).
Heck, just show them the part of the gifs before the room starts scrolling, for maximum objectivity. I think you'll find this so-called "gliding" to be preferable to choppy animation for most people. But then again, I could be wrong. I can only attest to the opinion of the few people I've shown those gifs to.
But it does seem to me as though the false consensus effect is strong with regards to this.  (nod)

ThreeOhFour

Quote from: Danvzare on Thu 03/10/2024 11:31:50it even removes the gliding effect that people like Snarky think MovementLinkedToAnimation is required to fix.

Preference is fine, everybody's taste is different. Just pointing out that this claim you made was incorrect.

DiegoHolt

Thanks to all of you for taking your time to reply.

And sorry for not posting any code! I guess I assumed everyone would know that I'm a rookie and my scripting is absolutely basic.

In the video I've posted, I'm using the player walking with transparency = 100

Now I've tried using some modules (rellax and smooth scroll) and setting to false MovementLinkedToAnimation, but now I'm getting side effects beacuse the screen lag is corrected but the walking animation is showing some issues. With the rellax module, my character looks kind of ghostly when the screen is scrolling. And with MovementLinkedToAnimation set to false, there is a little glitch when walking on the Y axis (up and down)

I'll post some videos later to show you what I mean.

Again, thank you all for sharing your knowledge and time!  :-D

Crimson Wizard

#16
Quote from: DiegoHolt on Thu 03/10/2024 18:15:58And sorry for not posting any code! I guess I assumed everyone would know that I'm a rookie and my scripting is absolutely basic.

In the video I've posted, I'm using the player walking with transparency = 100

Right, it's always essential to clarify how the behavior was achieved, because it cannot be obvious from the video: as visibly similar result may be achieved in a large number of ways.
For instance, I had no idea that you have a invisible player there, but I knew that it's potentially possible to make camera follow invisible character using a script, that's why I added a note about "late_repeatedly_execute.." (but since you are using builtin camera movement, that is not applicable, unless you script a custom one).

DiegoHolt

@Crimson Wizard actually I'm even more basic than that, because I didn't use any script for the camera to follow the invisible character. I just tried it and it worked. By the way, that character is the player.

Now I'm using the Tween module to move the camera, so that lag thing is covered. But I still see it when the player is walking. Any help there, please?

eri0o

Under the spoiler I hid a general explanation for rellax

Spoiler
If the character has movement linked to animation it will teleport the speed amount of pixels, then wait the delay of the frame, and then teleport again such amount of pixels that is set in the speed, which gives the perception that the character walks when it animates.

Rellax uses two different things to follow the player (I am going from my memory of my code...):

  • If the player is moving, it uses some lerp approach to interactively approach the actual camera target, which smooths it out
  • If the player is not moving, it will instead tween the camera to where it should be - this allows the camera to properly "lock" into target

If the player is walking very fast, the lerping approach will make the character ghost as the camera tries to catch-up with the player - if it's full scrolling, the camera is trying to keep the character in center. There are a few additional nuances in rellax but this is sort of the gist of it all.

I haven't been able to properly devise any way that it doesn't look so, but if the game is higher resolution and the character doesn't use movement linked to animation this is usually less perceptual.

The only way I think this could actually function is with floats for camera movement - this would allow the camera to position in fractions of pixels.
[close]

In actual games I have been able to workout the camera smoothing in a case by case basis, to avoid ghosting and all that, if you could show a video of the room where you are facing issue we could share ideas - one example, make areas and have the camera tween between areas when the player reach specific thresholds, but there are several approaches, you can even use tween+camera api to zoom out and zoom in.

Khris

You were dealing with a cutscene, so the tween module took care of that. During the game, the original issue is again what's causing this. The solution is again the SmoothScrolling module, which simply fixes the scrolling of the room being directly tied to the player's x coordinate and therefore being choppy.
I want to point out that in my very first reply over two days ago I correctly identified the cause of the issue and already posted a working solution (a link to the module) that fixes both the original issue and the current one.

SMF spam blocked by CleanTalk