- Home /
Problem is not reproducible or outdated
Why is the paralaxing shaky? (video examples)
https://drive.google.com/file/d/0ByYKDNm1mq0dVFNkZWlyZFV1ZVE/view?usp=sharing - 1st vid
https://drive.google.com/file/d/0ByYKDNm1mq0dY0ozcEtrck1vMTA/view?usp=sharing -2nd vid
http://pastebin.com/TZHBfMzy -the script for the obstacle movement
http://pastebin.com/iX05gYYB -the script for the background movement
Why does the movement lags so much? It's not from the laptop characteristics for sure (lenovo g510 i7 4700MQ, gpu radeon r7 265m). So this means it's either from the code although I see no reasons or smth else I'm doing wrong. Note how on the second video when I've reduced the gameSpeed 5 times still the platforms are shaky
UPDATE: It appeared that it's from the backgorund itself I removed the obstacles and found out that the backgound is the one that is shaky also left only the obstacles and they were fine so there's something wrong with the background. It's not the texture I changed the texture also. Tried to create a new project just to try the parallaxing and appeared that the same problem is there also ..
Answer by DMGregory · Dec 12, 2014 at 03:49 AM
Your platforms are moving using velocity. That means their position is being updated on FixedUpdate(), which is called ~50 times per second by default.
Your background is being repositioned on Update(), which is called once per rendered frame, which could be quite a lot more often if your framerate is high.
The difference between these two update rates can create judder like you're seeing.
For example, if you render at 30 fps with a physics step of 50 Hz, there are 5 physics updates for every 3 rendered frames; that means two thirds of your frames have 2 physics steps between them, but the odd frame out gets only one physics step (so the platforms seem to move less in that one frame compared to the others, making their movement look shaky).
One way to deal with it is to enable interpolation on your platform rigidbodies. What this does is offset the rendered transform in-between physics updates to give a smoother appearance. Interpolation: Extrapolate should predict correctly if your platforms are always moving at a constant velocity as shown here.
Switching both background & platforms to update the same way (either both in Update or both in FixedUpdate) will also fix any discrepancy between them, but might not be practical depending on their gameplay needs.
A more reliable fix is to move your camera instead of every co-moving object independently - fewer moving parts, fewer things can go wrong, and there's less data to interpolate. ;)
Thanks for the time spent answering my question I will try it! :)
Tried
One way to deal with it is to enable interpolation on your platform rigidbodies. What this does is offset the rendered transform in-between physics updates to give a smoother appearance. Interpolation: Extrapolate should predict correctly if your platforms are always moving at a constant velocity as shown here.
Switching both background & platforms to update the same way (either both in Update or both in FixedUpdate) will also fix any discrepancy between them, but might not be practical depending on their gameplay needs.
but still the shakyness is there I'd have tried the camera solution but I have some other logic in the game which doesn't allow me to do it
I actually removed the obstacles and found out that the shakiness comes from the very background.. not from the obstacles
Answer by blueLED · Dec 12, 2014 at 03:46 AM
How is the build performance though? I find everything is more fluid in the builds, from my experience. I thought this was normal because the editor is still running.
Follow this Question
Related Questions
Making a bubble level (not a game but work tool) 1 Answer
Speed up scrolling 2D background ends up jerky 2 Answers
my game when built on ios is not smooth. 2 Answers
Moving object top to down 2 Answers
Movement Script 1 Answer