1
00:00:00,000 --> 00:00:00,000
Hello, guys.

2
00:00:00,000 --> 00:00:04,000
I'm here to address one of the issues students text me about.

3
00:00:04,000 --> 00:00:06,000
It's parallax background.

4
00:00:06,000 --> 00:00:13,000
So student says when player runs ahead, the pull up the parallax background waves or flicks.

5
00:00:13,000 --> 00:00:14,000
I don't know why.

6
00:00:14,000 --> 00:00:15,000
Maybe camera ratios.

7
00:00:15,000 --> 00:00:21,000
I share the video and actually I didn't need to watch the video because I know what he's talking about.

8
00:00:21,000 --> 00:00:28,000
I faced the issue myself long time ago when I was recording this course for the first time, and I was

9
00:00:28,000 --> 00:00:32,000
afraid I will not find the solution and I cannot release a course with such a bug.

10
00:00:32,000 --> 00:00:38,000
But actually it's very easy to fix and solution is simple.

11
00:00:38,000 --> 00:00:41,000
And the reason it's happening is also very simple.

12
00:00:41,000 --> 00:00:43,000
It's very simple to understand.

13
00:00:43,000 --> 00:00:45,000
First, I want to show you.

14
00:00:46,000 --> 00:00:47,000
What he what he means.

15
00:00:47,000 --> 00:00:48,000
Let's see.

16
00:00:58,000 --> 00:01:00,000
And the video is very lucky.

17
00:01:00,000 --> 00:01:04,000
But still we can see the background flicks a bit shakes like that.

18
00:01:04,000 --> 00:01:12,000
And I have same on my project just a bit, especially if I go to Player's rigid body and change it from

19
00:01:12,000 --> 00:01:14,000
interpolate to none.

20
00:01:22,000 --> 00:01:23,000
You can see here.

21
00:01:23,000 --> 00:01:24,000
Where of my background?

22
00:01:24,000 --> 00:01:25,000
Over there.

23
00:01:25,000 --> 00:01:26,000
Right.

24
00:01:26,000 --> 00:01:28,000
So that's what they're talking about.

25
00:01:28,000 --> 00:01:34,000
Another student texted me with the same issue a while ago, and that's when I decided I need to make

26
00:01:34,000 --> 00:01:35,000
a video about it for sure.

27
00:01:35,000 --> 00:01:43,000
So it says he's in the background section and he's stuck because he cannot find the solution even when

28
00:01:43,000 --> 00:01:46,000
he uses different parallax code on YouTube.

29
00:01:47,000 --> 00:01:51,000
His further background tilts jiggles, shakes when he moves.

30
00:01:51,000 --> 00:01:56,000
So first of all, I'll show you a quick solution If you just want to know how to fix it.

31
00:01:56,000 --> 00:01:58,000
You don't want to know why it's happening.

32
00:01:58,000 --> 00:02:02,000
And actually, I showed the solution in my videos.

33
00:02:02,000 --> 00:02:05,000
It's very basically the same.

34
00:02:05,000 --> 00:02:06,000
But maybe it didn't help you.

35
00:02:07,000 --> 00:02:10,000
And I'll try to explain one more time.

36
00:02:10,000 --> 00:02:14,000
First of all, you need to set your rigid by this to interpolate.

37
00:02:14,000 --> 00:02:15,000
Interpolate.

38
00:02:15,000 --> 00:02:17,000
This is important.

39
00:02:17,000 --> 00:02:19,000
This is very important to do this.

40
00:02:19,000 --> 00:02:25,000
Second, you go to your main camera fine tuning machine brain change update method to smart update and

41
00:02:25,000 --> 00:02:28,000
blend method to later update.

42
00:02:28,000 --> 00:02:37,000
If it doesn't help you try to play with this, try to set up late update and late update here and just

43
00:02:37,000 --> 00:02:39,000
click these two couple of times.

44
00:02:39,000 --> 00:02:45,000
Maybe something will work better for you, but this what basically should be to make it work, I'm pretty

45
00:02:45,000 --> 00:02:46,000
sure.

46
00:02:46,000 --> 00:02:47,000
And.

47
00:02:48,000 --> 00:02:55,000
Even after you do this, you still may experience some deterrent effect, but it's going to be there

48
00:02:55,000 --> 00:02:56,000
only in unity.

49
00:02:56,000 --> 00:03:03,000
Ed Even in my videos later in the course when we setting up the canvas before we do the skybox, there

50
00:03:03,000 --> 00:03:08,000
is still some jittering of the mountains in the background and it is because of the unity.

51
00:03:08,000 --> 00:03:16,000
Only if you click over here to the stats, you can see your performance, space and CPU.

52
00:03:16,000 --> 00:03:22,000
And for some reason, I don't know if it's going to be there now, but sometimes for some reason when

53
00:03:22,000 --> 00:03:28,000
you move your mouse, unity has low performance issues and now it's jitter in the glitching.

54
00:03:28,000 --> 00:03:34,000
If I check my mouse, you can see my f-pace getting slightly lower.

55
00:03:34,000 --> 00:03:38,000
Not so much, but still it is there lower than it should be.

56
00:03:38,000 --> 00:03:43,000
And you can see MZ over here, the delay, it's getting up to six and seven.

57
00:03:43,000 --> 00:03:50,000
Again, it's not a big difference, but it's enough to make it lag on the background and if you thump

58
00:03:50,000 --> 00:03:54,000
the play mode and if you build your game, I'll go find, build and run.

59
00:03:58,000 --> 00:04:01,000
Look, when I build my game, I click top to start.

60
00:04:01,000 --> 00:04:04,000
I have no jittering on the background.

61
00:04:04,000 --> 00:04:04,000
It's all fine.

62
00:04:04,000 --> 00:04:07,000
You see, there is no lags, nothing.

63
00:04:08,000 --> 00:04:14,000
It works smoothly and nicely, basically perfect zero issues.

64
00:04:14,000 --> 00:04:16,000
So this is happening because.

65
00:04:17,000 --> 00:04:21,000
Mostly because of the unity ed and its own performance issue.

66
00:04:21,000 --> 00:04:25,000
So do, as I said, set up your rigid bodies to interpolate.

67
00:04:26,000 --> 00:04:33,000
Does that be a blend method on the cinema machine brain and make sure you have movement done in the

68
00:04:33,000 --> 00:04:34,000
update function.

69
00:04:35,000 --> 00:04:36,000
I'll show you what I mean by that.

70
00:04:36,000 --> 00:04:43,000
If you go to background Parallax on our script here, you can see it's done in the update.

71
00:04:44,000 --> 00:04:45,000
Player movement.

72
00:04:49,000 --> 00:04:50,000
Then in the update.

73
00:04:51,000 --> 00:04:58,000
Everything done in the update now smoothly, I'm going to transfer to explaining why this happening

74
00:04:58,000 --> 00:05:00,000
at all in the first place.

75
00:05:01,000 --> 00:05:06,000
You can actually ask this question in Google, and that's how I found the solution long time ago, like

76
00:05:06,000 --> 00:05:08,000
more than a year ago.

77
00:05:09,000 --> 00:05:11,000
But now it has like more short answer to the issue.

78
00:05:11,000 --> 00:05:16,000
So they basically discussed in same problem here determine problems with my camera.

79
00:05:16,000 --> 00:05:18,000
When doing a 2D parallax effect.

80
00:05:18,000 --> 00:05:22,000
I will leave link to this thread in the description.

81
00:05:22,000 --> 00:05:26,000
You can also find it in Google just by typing jittering background unity.

82
00:05:26,000 --> 00:05:30,000
There are lots of links discussed in this issue.

83
00:05:30,000 --> 00:05:38,000
Basically what they say is make sure you move in all objects, either in the fixed update or update.

84
00:05:38,000 --> 00:05:41,000
Don't mix them or you'll have endless headache.

85
00:05:43,000 --> 00:05:45,000
Then they discuss in some particular issue.

86
00:05:45,000 --> 00:05:53,000
And then Gregory from Unity Technology says since rendering is done on the update, late update clock

87
00:05:53,000 --> 00:05:57,000
same what we did here in the machine brain if you remember.

88
00:05:58,000 --> 00:05:58,000
Yeah.

89
00:05:59,000 --> 00:06:05,000
It's preferable to move all objects on the clock in order to reduce analyzing if you can.

90
00:06:05,000 --> 00:06:09,000
A good solution is to enable interpolate on rigid bodies.

91
00:06:09,000 --> 00:06:16,000
This will interpolate the transform physics between frames so that the position are appropriate for

92
00:06:16,000 --> 00:06:17,000
the current render time.

93
00:06:17,000 --> 00:06:24,000
Then you can run all your cameras in the late update and there will be no jitter.

94
00:06:24,000 --> 00:06:26,000
And that's what basically we did.

95
00:06:30,000 --> 00:06:36,000
If you remember, in the beginning of the course, I explained that there is a different type of update,

96
00:06:36,000 --> 00:06:39,000
fixed update, update and late update.

97
00:06:39,000 --> 00:06:44,000
So what he's saying basically is you need to decide how you're going to move your objects in the fixed

98
00:06:44,000 --> 00:06:51,000
update or late update and make sure you do it same across all of the objects in the game.

99
00:06:51,000 --> 00:06:56,000
And we chose update for that fixed update called 50 times per second by default.

100
00:06:56,000 --> 00:07:00,000
You can set up that in the edit project settings.

101
00:07:00,000 --> 00:07:01,000
Find the time over here.

102
00:07:02,000 --> 00:07:03,000
This is fixed time step.

103
00:07:03,000 --> 00:07:07,000
This one means it's called 50 times per second.

104
00:07:07,000 --> 00:07:14,000
If you want to make it called like five times per second, you can just increase the value and update

105
00:07:14,000 --> 00:07:16,000
can be called according to your face.

106
00:07:16,000 --> 00:07:22,000
If my space is 140, I'm going to be called 140 times per second.

107
00:07:22,000 --> 00:07:26,000
So yeah, I hope I explained why this is happening.

108
00:07:26,000 --> 00:07:33,000
It may happen because your objects moving in a different update or because you did not set a rigid body

109
00:07:33,000 --> 00:07:34,000
to interpolate.

110
00:07:36,000 --> 00:07:37,000
Make sure you do that.

111
00:07:37,000 --> 00:07:39,000
Make sure you set up your cinema machine.

112
00:07:39,000 --> 00:07:47,000
And even if it's happening after you did all of that, just make a build and see if it's still happening.

113
00:07:47,000 --> 00:07:50,000
If it's not happening when you build a game, then it's fine.

114
00:07:50,000 --> 00:07:56,000
You just work in unity, ignore it, and when your game is done, it won't be there.

115
00:07:57,000 --> 00:07:57,000
All right.

116
00:07:57,000 --> 00:07:58,000
Thank you for your attention.

117
00:07:58,000 --> 00:08:02,000
It was a lot of talking, none of nothing of coding, basically.

118
00:08:03,000 --> 00:08:05,000
But I see some people are getting confused.

119
00:08:05,000 --> 00:08:08,000
So I tried to cover the question here.

120
00:08:08,000 --> 00:08:10,000
I try to cover the issue.

121
00:08:10,000 --> 00:08:12,000
Check out the other courses.

122
00:08:12,000 --> 00:08:14,000
I'm releasing RPG course very soon.

123
00:08:14,000 --> 00:08:16,000
I hope you'll like that.

124
00:08:16,000 --> 00:08:22,000
It's going to be cool with the craft system and skill tree enemies Combat axe.

125
00:08:22,000 --> 00:08:23,000
So many cool stuff.

126
00:08:23,000 --> 00:08:24,000
So you.

