Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:06,656 --> 00:00:12,800
So whenever you wanted to move this player in various
2
00:00:13,056 --> 00:00:15,360
Directions maybe to left or to the right
3
00:00:15,872 --> 00:00:19,200
What do we do that is actually with something called variables
4
00:00:19,456 --> 00:00:24,576
Variables are declared or another way of putting it is there born or birth
5
00:00:25,088 --> 00:00:27,136
Before the start of function
6
00:00:27,648 --> 00:00:31,488
So let's come up with a variable called speed
7
00:00:31,744 --> 00:00:32,512
Private
8
00:00:33,792 --> 00:00:34,560
Float
9
00:00:35,328 --> 00:00:35,840
Speed
10
00:00:38,400 --> 00:00:38,912
Closet
11
00:00:39,680 --> 00:00:43,008
Basically what we've done here is we've spoken into existence
12
00:00:43,264 --> 00:00:46,592
A new variable and that variable is a float
13
00:00:46,848 --> 00:00:47,872
Godspeed
14
00:00:48,384 --> 00:00:54,528
You don't know the floor is that's ok I didn't know what a flow was either when I started scripting a flow is basically a decimal number
15
00:00:54,784 --> 00:01:00,525
Integers which is 12345 and someone in this float switch is 1.2
16
00:01:00,527 --> 00:01:02,875
Subtitled by
-♪ online-courses.club ♪-
We compress knowledge for you!
https://t.me/joinchat/ailxpXoW3JVjYzQ1
17
00:01:02,876 --> 00:01:04,000
554 2.33
18
00:01:04,512 --> 00:01:10,656
You want to use floats for Speed because it's slowly going to maybe Accelerate from €100 to
19
00:01:11,424 --> 00:01:11,936
So
20
00:01:12,192 --> 00:01:18,336
Speed could technically be 5.654 or we can make this
21
00:01:18,592 --> 00:01:20,128
That's a 1 point
22
00:01:20,384 --> 00:01:23,968
34567
23
00:01:24,736 --> 00:01:27,296
So that is our float for Speed
24
00:01:27,808 --> 00:01:31,648
Don't worry about this word private will talk about private and public in just 2
25
00:01:32,160 --> 00:01:35,488
First I want to talk about why you would use a variable
26
00:01:35,744 --> 00:01:37,792
Change this five
27
00:01:38,048 --> 00:01:39,584
Actually speed
28
00:01:40,352 --> 00:01:44,192
So what is Speedwell speed is 1.3 4 5 6 7
29
00:01:44,448 --> 00:01:50,592
So that means that are transformed position is going to move at the rate of 1
30
00:01:50,848 --> 00:01:52,384
34567
31
00:01:52,640 --> 00:01:54,688
Tell if we save
32
00:01:55,200 --> 00:01:56,224
Going the Unity
33
00:01:56,736 --> 00:01:57,504
Play
34
00:01:57,760 --> 00:02:00,064
You see the speed is now moving at that rate
35
00:02:01,856 --> 00:02:08,000
The reason you're gonna use variables because you want to be able to reuse them when you can or change them at
36
00:02:08,256 --> 00:02:08,768
10 time
37
00:02:09,280 --> 00:02:13,632
Self example what if in the start I said well actually want my speed to be
38
00:02:14,144 --> 00:02:15,936
5.55
39
00:02:16,192 --> 00:02:16,704
4
40
00:02:18,752 --> 00:02:19,264
Now
41
00:02:19,520 --> 00:02:22,080
Because this function is going to fire first
42
00:02:22,592 --> 00:02:26,432
Once we hit the update function speed is now going to be equal to this
43
00:02:27,200 --> 00:02:28,736
Save it down hip play
44
00:02:29,760 --> 00:02:31,296
This is moving like faster
45
00:02:33,088 --> 00:02:39,232
What are the cool things about variables that you can actually change them in the universe editor you actually have to write them
46
00:02:39,488 --> 00:02:40,768
In a script to change them
47
00:02:41,024 --> 00:02:42,560
Instead of doing that
48
00:02:43,072 --> 00:02:44,096
Delete that
49
00:02:44,864 --> 00:02:50,496
And we can actually do something called serialising a field so we can do serialise field
50
00:02:51,008 --> 00:02:53,824
All that means is there any inspector now
51
00:02:54,336 --> 00:02:56,384
You'll see the variable speed
52
00:02:56,640 --> 00:02:57,408
Right here
53
00:02:58,688 --> 00:03:00,224
Technically changed this year
54
00:03:00,736 --> 00:03:02,016
2.01
55
00:03:02,272 --> 00:03:04,064
It's going to override
56
00:03:04,320 --> 00:03:05,856
What we declared here
57
00:03:07,392 --> 00:03:09,696
That's cool because we have an enemy script
58
00:03:09,952 --> 00:03:13,280
Using it multiple times across maybe doesn't have enemies
59
00:03:13,536 --> 00:03:16,096
Maybe some enemies you want to move in a different way
60
00:03:16,864 --> 00:03:18,400
Go ahead play
61
00:03:19,424 --> 00:03:21,472
Moving very slowly can almost
62
00:03:21,728 --> 00:03:23,008
Barely see it
63
00:03:26,080 --> 00:03:28,640
And to change that variable at runtime
64
00:03:30,944 --> 00:03:32,992
Where we go or what about going backwards
65
00:03:34,528 --> 00:03:38,880
Here we go so that's the benefit of variables especially when they see realised
66
00:03:40,672 --> 00:03:44,512
Now we can do is actually happy if we wanted to he copy this player
67
00:03:45,024 --> 00:03:46,048
Multiple times
68
00:03:46,560 --> 00:03:48,096
Chelsea unit control
69
00:03:49,120 --> 00:03:52,704
How many could set each wind have different speeds of 1
70
00:03:54,752 --> 00:03:56,032
5
71
00:03:57,312 --> 00:03:59,104
-2
72
00:03:59,360 --> 00:04:00,384
And then hit way
73
00:04:04,224 --> 00:04:06,784
And so now I cannot take enemies patrolling
74
00:04:07,040 --> 00:04:07,808
Through the scene
75
00:04:08,832 --> 00:04:11,392
That's the benefit of having serialised Fields
76
00:04:13,440 --> 00:04:14,720
My inspector here
77
00:04:17,280 --> 00:04:18,559
That's a float
78
00:04:18,815 --> 00:04:20,351
Does other kinds of variables as well
79
00:04:20,863 --> 00:04:22,143
Is also bullying
80
00:04:23,935 --> 00:04:24,959
Private bullion
81
00:04:25,471 --> 00:04:25,983
Dead
82
00:04:27,519 --> 00:04:29,567
A bullying is basically true or false
83
00:04:32,383 --> 00:04:33,663
I'm like a float
84
00:04:34,175 --> 00:04:40,319
True or false is either basically 1 or 0 and can be anything else one being true
85
00:04:40,575 --> 00:04:41,087
False
86
00:04:41,343 --> 00:04:44,159
Even what use the words true or false
87
00:04:45,439 --> 00:04:47,743
Dead is going to be true or false
88
00:04:47,999 --> 00:04:50,047
By default can be false
89
00:04:51,071 --> 00:04:57,215
So would want to start a live so we're not dead which is private
90
00:04:59,263 --> 00:05:02,847
And this would be health help would be an integer you either
91
00:05:03,103 --> 00:05:08,479
10 9876543210
92
00:05:08,735 --> 00:05:11,295
That's a good use of an integer help
93
00:05:11,551 --> 00:05:15,391
Now you should be something like a coin there's you can't really have
94
00:05:15,647 --> 00:05:17,439
3.5 pennies
95
00:05:17,695 --> 00:05:18,719
In real life
96
00:05:18,975 --> 00:05:22,303
You can either have three or four so that's the use of an integer
97
00:05:23,327 --> 00:05:24,607
There's also
98
00:05:24,863 --> 00:05:26,143
Strings
99
00:05:27,167 --> 00:05:29,215
So I say what's my name
100
00:05:30,239 --> 00:05:32,543
Well we could are call herself Billy
101
00:05:34,079 --> 00:05:35,615
That is a string
102
00:05:35,871 --> 00:05:42,015
The reason why there's a green zig zag line is because there's actually variables called name already
103
00:05:42,527 --> 00:05:44,319
Inside of a monobehaviour
104
00:05:44,575 --> 00:05:47,391
So we really don't want to use that cos I can get a little bit
105
00:05:47,647 --> 00:05:49,439
So what we do player name
106
00:05:50,463 --> 00:05:51,231
Here we go
107
00:05:51,999 --> 00:05:54,815
Universe all of my variables are lowercase
108
00:05:55,071 --> 00:05:57,375
All variables should be lowercase
109
00:05:57,631 --> 00:05:58,911
Without spaces
110
00:05:59,167 --> 00:06:01,215
You can use underscores if you like
111
00:06:01,727 --> 00:06:05,311
But I tend to just you lowercase and then anytime is a new word
112
00:06:05,567 --> 00:06:09,663
Abaqus scripting classes on the other hand or uppercase
113
00:06:09,919 --> 00:06:11,967
In functions are uppercase as well
114
00:06:12,735 --> 00:06:16,575
Definitely want to follow this rule especially going to be working with the team and just
115
00:06:16,831 --> 00:06:18,623
Funny I'm working on a game long term
116
00:06:18,879 --> 00:06:21,951
Switch it on for crazy and don't pick your team members go crazy
117
00:06:22,207 --> 00:06:26,815
To keep your variables lowercase with uppercase anytime you have a new word in that variable
118
00:06:27,327 --> 00:06:30,143
An app that starting a new function
119
00:06:30,399 --> 00:06:30,911
Or
120
00:06:31,935 --> 00:06:32,703
Naming a scrim
121
00:06:33,471 --> 00:06:38,591
So again if we save these out you never said nothing is actually showing up in the inspector
122
00:06:39,103 --> 00:06:40,127
Because remember
123
00:06:40,383 --> 00:06:42,431
We need abuse the serializefield
124
00:06:43,199 --> 00:06:44,223
Actually show them
125
00:06:45,247 --> 00:06:46,271
Indeed inspector
126
00:06:46,527 --> 00:06:48,575
Search back in inspector
127
00:06:49,087 --> 00:06:50,623
Can you see they're all here
128
00:06:50,879 --> 00:06:52,671
Set Dead true everyone
129
00:06:52,927 --> 00:06:53,951
The more we play
130
00:06:54,207 --> 00:06:56,255
We have the health set to 10
131
00:06:56,767 --> 00:06:58,303
Maybe for some players
132
00:06:58,815 --> 00:07:02,399
I characters we can do the health and safety and maybe his name is
133
00:07:02,911 --> 00:07:03,423
Jack
134
00:07:04,959 --> 00:07:05,471
And
135
00:07:06,495 --> 00:07:07,263
Sammy
136
00:07:08,031 --> 00:07:09,567
With the help of 25
137
00:07:10,079 --> 00:07:12,895
Now let's talk about what private means
138
00:07:13,151 --> 00:07:19,295
A private variable is basically something that only going to be accessed by this script
139
00:07:19,551 --> 00:07:21,855
What about a script called enemy
140
00:07:22,367 --> 00:07:25,183
Well if enemy wanted to let say
141
00:07:26,207 --> 00:07:27,999
Set Dead to false
142
00:07:28,511 --> 00:07:32,351
Or Set Dead 2 true for the player I couldn't actually do it
143
00:07:32,863 --> 00:07:34,143
Because it said the private
144
00:07:34,911 --> 00:07:41,055
This variable dead in this very bad health and the name the speed only
145
00:07:41,311 --> 00:07:44,383
This class can adjust these variables
146
00:07:45,151 --> 00:07:46,175
Apollo variable
147
00:07:46,943 --> 00:07:49,247
Actually means that any script
148
00:07:49,503 --> 00:07:51,295
Any script inside of Unity
149
00:07:51,551 --> 00:07:57,695
Whether the enemy script or a weapon script or a bullet straight or anything
150
00:07:57,951 --> 00:08:00,255
Access this variable in change it
151
00:08:00,511 --> 00:08:06,655
No call thing about public variables if you don't actually need to serialise them because hey the public say
152
00:08:06,911 --> 00:08:10,751
Even unity the editor is going to have access to that
153
00:08:11,519 --> 00:08:15,615
So even though we don't have serialise written here before the speed variable
154
00:08:15,871 --> 00:08:17,663
United States still there
155
00:08:18,687 --> 00:08:20,479
But the moment we make it private
156
00:08:23,295 --> 00:08:24,063
Disappear
157
00:08:26,623 --> 00:08:27,391
Basically
158
00:08:27,647 --> 00:08:33,791
Every variable by default should always be private you should only said at the pub
159
00:08:34,047 --> 00:08:37,375
If you know for certain that you need to access that variable
160
00:08:37,631 --> 00:08:43,775
From a different script we're going to be creating an entire prototype and we're going to using private and public variables
161
00:08:44,031 --> 00:08:46,335
Don't worry if this doesn't make sense just yet
162
00:08:47,103 --> 00:08:52,735
So getting the recap we have floats which are decimal numbers speed is a good way of using a float
163
00:08:52,991 --> 00:08:55,295
We all have brilliant which are true and false
164
00:08:55,807 --> 00:09:01,951
Remembering integer is single number 01234 basically digits
165
00:09:02,207 --> 00:09:06,815
And then finally strings which are actual names and they always appear inside
166
00:09:07,071 --> 00:09:07,839
Quote
167
00:09:09,375 --> 00:09:10,655
And then a word
12251
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.