Page 1 of 1

Camera feeling shaky

Posted: Tue Jul 30, 2024 2:10 pm
by snibo
Hello everyone I am trying to make a small rpg and when I got to making the movement and the camera I realized that it had a bunch of issues
Look at the video
[youtube]https://youtu.be/TQ6l7zjFonM?si=wgvBAa3gvbP5CHJF[/youtube]
Now you might understand what I mean the background seems to not be keeping up with the player and it also get a bit blurry whenever I moved wich is a bit nauseating to me

Si if someone know how to fix the choppiness and blurriness issues please tell me because I couldn't find anything on my own

Re: Camera feeling shaky

Posted: Tue Jul 30, 2024 2:30 pm
by zorg
Don't forget to math.floor camera coordinates, that might help.

Re: Camera feeling shaky

Posted: Tue Jul 30, 2024 2:34 pm
by snibo
zorg wrote: Tue Jul 30, 2024 2:30 pm Don't forget to math.floor camera coordinates, that might help.
How do i do that?

Edit: I have figured out how to do it but all that did is amplify the snapping effect wich I don't really like and it also didn't fix the blurryness problem because when they switched to the next pixel it had the ugly quick blur in between the snapping

Re: Camera feeling shaky

Posted: Tue Jul 30, 2024 11:29 pm
by slime
It's hard to guess what needs to be fixed without seeing what your code is doing. Can you upload your project here as a .love file?

Re: Camera feeling shaky

Posted: Wed Jul 31, 2024 8:04 am
by snibo
slime wrote: Tue Jul 30, 2024 11:29 pm It's hard to guess what needs to be fixed without seeing what your code is doing. Can you upload your project here as a .love file?
Sur man. I just thought that it would be a more general question but you can see the code if you want to

Re: Camera feeling shaky

Posted: Wed Jul 31, 2024 10:53 am
by marclurr
Because your camera is locked the player position, flooring just the camera makes the player look more "jittery". You need to floor both to see the improvement, but you should only floor the player position input to the draw function call, otherwise you'll lose any fractional position information. For example, do something like this:

Code: Select all

love.graphics.draw(player.sprite, math.floor(player.x), math.floor(player.y), nil, 2*player.scale, nil, 16, 26)
Instead of flooring you might want to try rounding to the nearest whole value. Sometimes that can make things look better, you should experiment with both.

The other thing you might notice is not jittering but an odd "staircase" looking affect when the player moves diagonally. This is a quirk of working at low resolutions. If you want to go down a rabbit hole there are some things you can do to improve it. This is an interesting video about that exact topic, in the context of making a shmup at a very low resolution (128x128) https://www.youtube.com/watch?v=stoDWgR-kF8&t=1451s

Re: Camera feeling shaky

Posted: Wed Jul 31, 2024 1:46 pm
by snibo
Ok so I watched the video and his solution was not only flooring but adding 0.5 that way it gets to the senter of the pixel my only issue is that it doesn't seem to be 0.5 in love2d I feel like it's lower do you know what value should I use for it

Re: Camera feeling shaky

Posted: Wed Jul 31, 2024 2:02 pm
by marclurr
It will be the same in Love2D, but his solution is more complex than just 0.5 then floor. All of his code works together to give the nice diagonal movement. Make sure you're happy with the player/camera stuff before implementing what's in that video.

Re: Camera feeling shaky

Posted: Wed Jul 31, 2024 2:19 pm
by snibo
You know what I think that I am trying to fix the wrong problem by removing all the flooring and stuff I feel like it looks better, my issue with it is that the movement felt inconsistent where sometimes everything is very smooth and sodenly it changes place I don't know how to say it and flooring just amplifies the snapping effect wich I don't like