Platforms with different speeds look jerky

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
pacman
Citizen
Posts: 81
Joined: Thu Mar 14, 2013 4:10 pm

Platforms with different speeds look jerky

Post by pacman »

Hi o/

In .love file I have constantly spawning platforms with randomized speed.
Camera is attached to the player.
When player stands on the ground everything looks smooth - no problem.
But when you jump on a platform other platforms looks really jerky.

You can press "S" to slow the time. In slowmotion everything looks okay.
That's why I think everything works fine and the jerkiness is unavoidable :c

Is there any way to solve this problem?

Keys:
A D - movement
S - slow down the time
P - jump
Attachments
PlatformTest.love
(2.49 MiB) Downloaded 202 times
Clouds
Prole
Posts: 23
Joined: Tue Nov 27, 2012 4:06 am

Re: Platforms with different speeds look jerky

Post by Clouds »

Well, it depends what you mean...

I tried it, and other platforms' motions look a bit unsmooth when I'm riding on one...even in slow motion. I wouldn't call it "really jerky". "Really jerky" is what I'd call this problem.

If you just mean the slightly unsmooth, kind of "gritty"-seeming motion, I think that's unavoidable when you have platforms that move asynchronously. Because the camera pans when the platform you are on rises, all the other platforms appear to move "down" with the background. Then, when they rise, they step "up" one. Because these two opposing motions don't always happen in unison, you can sort of see the other platforms vibrating up and down and up and down, especially since you use double-pixels.
User avatar
pacman
Citizen
Posts: 81
Joined: Thu Mar 14, 2013 4:10 pm

Re: Platforms with different speeds look jerky

Post by pacman »

I can't think of any NES game that would use multiple platforms with different velocities.
It would require some synchronization with the platform player is standing on.
And that would be crazy :rofl:
I guess the best solution is increasing the speed of platforms to make the tearing/jerking/flickering less obvious :o:
User avatar
verilog
Citizen
Posts: 97
Joined: Thu Nov 03, 2011 3:15 am
Contact:

Re: Platforms with different speeds look jerky

Post by verilog »

Hi pacman!
Something is definitely up. It is hard to pin-point the exact cause, but I've also encountered this issue. Unfortunately I can't remember how (if) I really solved it. However, I have some suggestions for your. Hopefully we'll be able to identify the problem. Increasing the speed of the moving objects is a temporal work around, not a solution. I remember doing the exact same thing only to discover the issue persisted under other conditions.

I thought that might be a discrepancy with the way we update the new platform's position and the actual position that is used to draw the entities. Make sure you update positions and then draw the updated information. I also believed that there may be something wrong with the way we are integrating velocities. There's some info on implementing a correct integration model here and here.

As I said, I stumbled upon the same problem and I'm not quite sure if I actually managed to solve it, but the problem definitely exists. I'm certain that there's something with the way new object positions are being computed or drawn. I will reflect upon the matter and report back if I find anything!

Edit: That game is looking really nice!
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Platforms with different speeds look jerky

Post by davisdude »

Those are some nice links you posted there. I'll have to keep those in mind. :)
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Platforms with different speeds look jerky

Post by micha »

I am pretty sure, this is not a problem of the integration scheme, but rather a problem of the pixel style. As you are using pixel art, you are forced to round the coordinates of everything to the nearest integer. Now let's say you have two platforms with a similar but different speed and let's say they move less than one pixel per frame. In other words, in some frames, they move by one pixel and in some frames the do not. When the two platforms have a different speed, then the frames in which they move are different. Now from time to time it happens, that the first platform moves up by one pixel while the other stands still. In some other times, the second one moves while the first one does not move.

That means, that if you are standing on one of the two platforms, then the other one seems to move both up and down from time to time.

Put differently, this phenomenon happens, because you are looking at the difference of two rounded numbers. First the coordinates of the platforms are rounded and then the difference is considered (because the camera shift is attached to one of the platforms). One possible solution would be to first calculate the difference and then round it once. But that would mean that you cannot simply use a camera module. So this approach is unpractical.

Here are two more idea. These do not totally solve the issue, but minimize the effect. First you can implement a camera with momentum. Instead of attaching the camera to the player perfectly, make it follow the player smoothly. And second, try to avoid platforms with almost the same speed.
User avatar
pacman
Citizen
Posts: 81
Joined: Thu Mar 14, 2013 4:10 pm

Re: Platforms with different speeds look jerky

Post by pacman »

verilog wrote:There's some info on implementing a correct integration model here and here.
Really nice info there! :3
But it's not a source of the problem. Good thing is I don't need much accuracy to calculate 30px height jumps :awesome:
micha wrote:First you can implement a camera with momentum. Instead of attaching the camera to the player perfectly, make it follow the player smoothly. And second, try to avoid platforms with almost the same speed.
I tried smooth camera work and it's just not good idea for a game like that :o:
Everything is too slow and small adjustments of the camera have this jerkiness.

Second solution is decent! ;>
I guess having platforms that goes half or twice the speed would still look okay.
User avatar
pacman
Citizen
Posts: 81
Joined: Thu Mar 14, 2013 4:10 pm

Re: Platforms with different speeds look jerky

Post by pacman »

Someone kill me, please :emo:

After setting every platform to the same speed it's still vibrating occasionally.
Now, I think I know what causes it.

Platform #1 spawns and at some point it has Y-value: 100.38912656513
Platform #2 spawns and at the beggining it has Y-value: 0.000000000
Now when we're adding dt, Platform #1 will reach next pixel 100.600012314 value (displayed at 101 because of rounding) when Platform #2 will still be around 0.38130513623 so it doesn't move.
That's how we get two platforms with same velocities beeing jerky (if camera will be relative to one of the platforms).

Sounds like a common problem, is it? :roll:
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Platforms with different speeds look jerky

Post by micha »

Yes, that is the correct reason.

As I said above, you can also solve this, if you are willing to rewrite your camera library. Internally you have to change the order of subtracting numbers and rounding numbers.
A standard camera library has an position of the camera (which can be non-integers). To avoid blurring, this position is internally rounded to an integer. Then each game object has some (non-integer) coordinates, which are rounded before they are drawn. Again, this avoids blurring of the images. When the camera is applied, then internally, the camera coordinates are subtracted from the object coordinates (by using love.graphics.translate). So effectively you get the difference of two rounded numbers.

But what you want is the difference of the (not-rounded, non-integer) numbers and then round it afterwards. To get that, allow the camera coordinates and all object coordinates to be non-integers. Then, instead of using love.graphics.translate, subtract the camera coordinates from all object coordinates, then round these numbers and draw the objects.
User avatar
pacman
Citizen
Posts: 81
Joined: Thu Mar 14, 2013 4:10 pm

Re: Platforms with different speeds look jerky

Post by pacman »

Did anyone wrote any tutorial/article about this topic?
There is no point in using camera that works only in certain circumstances.
Will investigate! Thank you, Watson :crazy: Game saver!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 44 guests