1 00:00:00,000 --> 00:00:00,200 2 00:00:00,200 --> 00:00:01,741 LONDON LOWMANSTONE: So, hi everybody. 3 00:00:01,741 --> 00:00:05,140 Welcome to the CS50 seminar, Create Your Own Virtual Reality. 4 00:00:05,140 --> 00:00:07,841 I'm London Lowmanstone and I'll be teaching the seminar. 5 00:00:07,841 --> 00:00:10,090 So the first thing I want to talk about is what you're 6 00:00:10,090 --> 00:00:11,800 going to learn during the seminar. 7 00:00:11,800 --> 00:00:15,790 We're going to figure out how to create a the virtual reality app 8 00:00:15,790 --> 00:00:19,210 in a certain environment called Unity. 9 00:00:19,210 --> 00:00:22,510 And we're also going to be able to upload this app to an iPhone 10 00:00:22,510 --> 00:00:23,680 by the time we're done. 11 00:00:23,680 --> 00:00:26,200 I don't have any experience with Android, unfortunately. 12 00:00:26,200 --> 00:00:28,120 So if you have an Android phone-- 13 00:00:28,120 --> 00:00:32,562 personally, I learned all of this stuff by doing Google searches last year. 14 00:00:32,562 --> 00:00:34,270 And so, if you have an Android phone, I'm 15 00:00:34,270 --> 00:00:37,330 pretty sure it's fairly easy to go online, find searches, and figure out 16 00:00:37,330 --> 00:00:38,740 how to upload it to Android. 17 00:00:38,740 --> 00:00:43,570 I have an iPhone, so that's the process that I'm going to show here today. 18 00:00:43,570 --> 00:00:46,410 So, for a set up, you're probably going to want to remember 19 00:00:46,410 --> 00:00:48,234 this URL so you can access the page. 20 00:00:48,234 --> 00:00:50,400 All of these instructions, plus a couple more hints, 21 00:00:50,400 --> 00:00:56,590 are available at bit.ly/vrseminar And so, if you follow that link, 22 00:00:56,590 --> 00:00:59,950 you'll get access to a page that has all this information plus more. 23 00:00:59,950 --> 00:01:03,186 So the first thing you're going to want to do is install Unity Personal. 24 00:01:03,186 --> 00:01:04,769 Personal is the free version of Unity. 25 00:01:04,769 --> 00:01:09,000 And as long as you're not using Unity to make more than $10,000, 26 00:01:09,000 --> 00:01:10,980 you should be able to download Unity Personal 27 00:01:10,980 --> 00:01:14,050 and use it for free, which is pretty awesome. 28 00:01:14,050 --> 00:01:16,410 I think Unity will install Monodevelop. 29 00:01:16,410 --> 00:01:18,930 If not, then you should also install Monodevelop. 30 00:01:18,930 --> 00:01:20,640 It's the programming for Unity. 31 00:01:20,640 --> 00:01:23,820 So whenever we need to code something, it will be in Monodevelop. 32 00:01:23,820 --> 00:01:27,120 And if you're on a Windows computer, Microsoft Visual Studio 33 00:01:27,120 --> 00:01:29,460 will suffice, as well. 34 00:01:29,460 --> 00:01:32,250 There is the download for Monodevelop. 35 00:01:32,250 --> 00:01:35,580 And then, in terms of actually using Google Cardboard-- so 36 00:01:35,580 --> 00:01:37,500 Google Cardboard is this thing right here. 37 00:01:37,500 --> 00:01:39,060 It's a virtual reality device. 38 00:01:39,060 --> 00:01:43,440 It unfolds and it becomes like a little box that you can put your phone into. 39 00:01:43,440 --> 00:01:46,710 You're going to need to download the SDK for Google Cardboard. 40 00:01:46,710 --> 00:01:50,040 And that will be a source code zip folder. 41 00:01:50,040 --> 00:01:54,530 And you can download it at this URL here or this one here. 42 00:01:54,530 --> 00:01:57,590 And then if you have an iPhone, and you want 43 00:01:57,590 --> 00:01:59,690 to be able to upload it to your iPhone, you 44 00:01:59,690 --> 00:02:04,490 should download the iPhone programming language, or IDE for programming, 45 00:02:04,490 --> 00:02:05,630 called Xcode. 46 00:02:05,630 --> 00:02:07,100 Get a developer account. 47 00:02:07,100 --> 00:02:09,080 And then you should also register your phone 48 00:02:09,080 --> 00:02:14,694 as a Developer's, like, device that you can then upload things to. 49 00:02:14,694 --> 00:02:16,610 So it might take a while, but it's only needed 50 00:02:16,610 --> 00:02:19,312 for the last step of actually uploading things to your phone. 51 00:02:19,312 --> 00:02:21,020 And then, for the final step, you'll need 52 00:02:21,020 --> 00:02:23,390 to actually buy a Google Cardboard. 53 00:02:23,390 --> 00:02:24,980 It should be less than $10. 54 00:02:24,980 --> 00:02:27,569 This is the only step that should cost any money, whatsoever. 55 00:02:27,569 --> 00:02:29,360 The rest of everything else should be free, 56 00:02:29,360 --> 00:02:31,901 which is something that I really like about Google Cardboard. 57 00:02:31,901 --> 00:02:33,650 So total cost should be less than $10. 58 00:02:33,650 --> 00:02:36,270 59 00:02:36,270 --> 00:02:38,400 So what is virtual reality? 60 00:02:38,400 --> 00:02:43,020 I like to think of virtual reality as separate from these other two types 61 00:02:43,020 --> 00:02:48,250 of virtual-like realities, which are AR and mixed realities. 62 00:02:48,250 --> 00:02:50,160 So AR is augmented reality. 63 00:02:50,160 --> 00:02:54,390 It's when you have a space like this, and you look around, 64 00:02:54,390 --> 00:02:58,110 and it will basically display data on the information around you. 65 00:02:58,110 --> 00:02:59,700 That's augmented reality. 66 00:02:59,700 --> 00:03:03,300 You can also be in the real world and put on, like, glasses or whatnot 67 00:03:03,300 --> 00:03:05,680 and interact with virtual objects. 68 00:03:05,680 --> 00:03:07,210 And that's called mixed reality. 69 00:03:07,210 --> 00:03:09,670 Virtual reality is when everything around you is virtual. 70 00:03:09,670 --> 00:03:11,670 So you have no interactions with the real world. 71 00:03:11,670 --> 00:03:14,190 It's all a complete virtual reality. 72 00:03:14,190 --> 00:03:15,810 So this has many applications. 73 00:03:15,810 --> 00:03:17,700 You can imagine, easy ones for entertainment, 74 00:03:17,700 --> 00:03:20,610 where 3D movies are pretty darned cool. 75 00:03:20,610 --> 00:03:22,890 Job training, where you can have people learn things 76 00:03:22,890 --> 00:03:26,040 about their job or interact with virtual simulator 77 00:03:26,040 --> 00:03:28,330 to learn how to do the job for the first time. 78 00:03:28,330 --> 00:03:30,684 It can also be super useful for remote controls. 79 00:03:30,684 --> 00:03:32,850 So, if you imagine you're, like, flying an airplane, 80 00:03:32,850 --> 00:03:35,433 but you're in a virtual reality version of the actual airplane 81 00:03:35,433 --> 00:03:36,390 that you're flying. 82 00:03:36,390 --> 00:03:39,270 And, in my opinion, it's kind of starting to take off. 83 00:03:39,270 --> 00:03:42,990 There are lots of new devices ranging from all sorts of different ways 84 00:03:42,990 --> 00:03:44,820 to put on virtual reality. 85 00:03:44,820 --> 00:03:48,510 There's Microsoft HoloLens and Oculus Rift and a whole bunch of other things. 86 00:03:48,510 --> 00:03:51,210 HoloLens might be considered more AR or mixed reality. 87 00:03:51,210 --> 00:03:54,780 But anyhow, all this type of stuff is getting extremely popular. 88 00:03:54,780 --> 00:03:57,660 And I think it's really cool that you can make it for under $10. 89 00:03:57,660 --> 00:04:00,326 There's also many new audiences that are being introduced to it. 90 00:04:00,326 --> 00:04:02,730 One of the coolest things I saw was Lockheed Martin, 91 00:04:02,730 --> 00:04:07,170 a company created a bus where they had virtual reality displayed 92 00:04:07,170 --> 00:04:11,860 on the windows, so that kids took a bus field trip on the surface of Mars. 93 00:04:11,860 --> 00:04:14,040 So as they took turns down street, they actually 94 00:04:14,040 --> 00:04:16,589 mapped the streets onto the surface of Mars 95 00:04:16,589 --> 00:04:20,296 and were able to get people to feel like they are on Mars and experience that. 96 00:04:20,296 --> 00:04:22,170 So I thought that that was a super cool thing 97 00:04:22,170 --> 00:04:25,310 that you could do with virtual reality. 98 00:04:25,310 --> 00:04:26,900 So now let's get started. 99 00:04:26,900 --> 00:04:31,257 As I mentioned before, this is all stuff that I learned from Googling last year 100 00:04:31,257 --> 00:04:34,090 because I was interested in virtual reality and [INAUDIBLE] my class 101 00:04:34,090 --> 00:04:34,589 and did it. 102 00:04:34,589 --> 00:04:37,270 So I have no formal training in this whatsoever, 103 00:04:37,270 --> 00:04:39,970 and this is just what I've learned from searching online. 104 00:04:39,970 --> 00:04:44,500 So you can find almost all of this information, if not all of it, online. 105 00:04:44,500 --> 00:04:46,750 And of course, in the seminar. 106 00:04:46,750 --> 00:04:50,306 So Unity is an engine for creating your 3-D world. 107 00:04:50,306 --> 00:04:52,930 We'll be using some other things to actually do the programming 108 00:04:52,930 --> 00:04:54,250 and uploading it to your phone. 109 00:04:54,250 --> 00:04:57,430 But for the actual world, that's all going to be done in Unity. 110 00:04:57,430 --> 00:05:01,370 It makes it really easy to build virtual reality apps. 111 00:05:01,370 --> 00:05:05,620 And it's completely free, as long as you're not making more than $10,000, 112 00:05:05,620 --> 00:05:09,910 which probably you're not-- given that you haven't made an app yet. 113 00:05:09,910 --> 00:05:13,270 So let's set up our world for virtual reality. 114 00:05:13,270 --> 00:05:16,520 I'll make note here that I have a whole lot of slides, 115 00:05:16,520 --> 00:05:19,600 but really, most of the stuff we're going to be doing is on Unity. 116 00:05:19,600 --> 00:05:21,790 So I'll kind of discard the slides at this point. 117 00:05:21,790 --> 00:05:25,346 We might come back to it just to get a hang on some other stuff. 118 00:05:25,346 --> 00:05:27,970 But most of the stuff we'll be doing will actually be on Unity. 119 00:05:27,970 --> 00:05:31,840 So first we're going to create a new project, import the SDK 120 00:05:31,840 --> 00:05:33,870 that we downloaded for Google Cardboard. 121 00:05:33,870 --> 00:05:35,830 We'll choose the layout for our project. 122 00:05:35,830 --> 00:05:39,200 I happen to prefer some other layouts, but we'll stick with the default one. 123 00:05:39,200 --> 00:05:41,090 And I'll just show you guys how that works. 124 00:05:41,090 --> 00:05:43,330 We're going to add in this cardboard main pre-fab 125 00:05:43,330 --> 00:05:44,830 and then delete the main camera. 126 00:05:44,830 --> 00:05:46,227 And we'll have virtual reality. 127 00:05:46,227 --> 00:05:47,560 It won't have any objects in it. 128 00:05:47,560 --> 00:05:49,120 And that's what we'll do after this. 129 00:05:49,120 --> 00:05:51,650 So if you open up Unity-- 130 00:05:51,650 --> 00:05:55,690 Unity should look like this if you downloaded it. 131 00:05:55,690 --> 00:05:58,270 You can say file. 132 00:05:58,270 --> 00:06:01,000 And there should be something that says New Project right here. 133 00:06:01,000 --> 00:06:03,880 For you, it will be bold and allow you to open up a new project. 134 00:06:03,880 --> 00:06:05,680 Or you can click this button here. 135 00:06:05,680 --> 00:06:07,710 And then let's name this-- 136 00:06:07,710 --> 00:06:12,500 so CS50 Seminar VR World-- 137 00:06:12,500 --> 00:06:14,000 if I can spell world-- 138 00:06:14,000 --> 00:06:15,410 OK. 139 00:06:15,410 --> 00:06:18,160 And then, I don't really need Unity analytics. 140 00:06:18,160 --> 00:06:20,490 It gives you some data about your projects. 141 00:06:20,490 --> 00:06:23,970 And then you can also choose what location you want to store this on. 142 00:06:23,970 --> 00:06:31,260 So I'm going to go to hard drive and store it in CS50 Seminar. 143 00:06:31,260 --> 00:06:34,750 So that's the folder that's going to contain this entire project. 144 00:06:34,750 --> 00:06:36,360 So now I can say, Create Project. 145 00:06:36,360 --> 00:06:39,210 You also want to make sure that it's 3-D, not a 2-D project. 146 00:06:39,210 --> 00:06:41,700 Unity can be used to build both versions of apps. 147 00:06:41,700 --> 00:06:44,890 And so you want to make sure that it's the 3-D version because we're going 148 00:06:44,890 --> 00:06:47,790 to make a 3-D virtual reality world. 149 00:06:47,790 --> 00:06:49,451 So this is our virtual reality world. 150 00:06:49,451 --> 00:06:51,450 We'll stick with something close to the default. 151 00:06:51,450 --> 00:06:55,290 If you want to change how your layout works, 152 00:06:55,290 --> 00:06:57,831 you can actually drag all these little tabs around. 153 00:06:57,831 --> 00:07:00,330 So this is, like, going to be the game tab where we actually 154 00:07:00,330 --> 00:07:01,680 see what's going on. 155 00:07:01,680 --> 00:07:04,740 This is the scene tab where we can build up the scene. 156 00:07:04,740 --> 00:07:08,310 And the game is where we actually run and play stuff. 157 00:07:08,310 --> 00:07:09,650 This is our Project tab. 158 00:07:09,650 --> 00:07:12,017 It's going to hold all of the folders and things 159 00:07:12,017 --> 00:07:14,850 that we import into our project and all the, like, objects and stuff 160 00:07:14,850 --> 00:07:16,620 that we use to create the scenes. 161 00:07:16,620 --> 00:07:19,870 And then over here is going to be our hierarchy. 162 00:07:19,870 --> 00:07:23,605 And it's going to have all of the objects that we have into our games. 163 00:07:23,605 --> 00:07:26,040 So if we, like, create a ball or create terrain, 164 00:07:26,040 --> 00:07:28,510 these are all going to show up here. 165 00:07:28,510 --> 00:07:33,330 So the first thing we're going to do is import the SDK from Google Cardboard. 166 00:07:33,330 --> 00:07:36,760 So in order to do this, you can go to Assets-- 167 00:07:36,760 --> 00:07:41,300 Import Package-- and this is going to be a custom package. 168 00:07:41,300 --> 00:07:43,950 I believe I still have mine-- 169 00:07:43,950 --> 00:07:44,450 oh, look. 170 00:07:44,450 --> 00:07:45,530 Comes up right here. 171 00:07:45,530 --> 00:07:47,990 So it depends on where you have your package. 172 00:07:47,990 --> 00:07:50,180 Mine-- I still have in my Downloads folder. 173 00:07:50,180 --> 00:07:51,860 And so you open up that folder-- 174 00:07:51,860 --> 00:07:56,480 GBR Unity SDK 0.6 and that should give you the Unity package. 175 00:07:56,480 --> 00:08:00,080 Do make sure that when you download the SDK, you're downloading 0.6-- 176 00:08:00,080 --> 00:08:02,600 I haven't gotten the newer versions to work with Unity 177 00:08:02,600 --> 00:08:04,190 and uploading to my iPhone yet. 178 00:08:04,190 --> 00:08:07,100 So make sure you are installing that old version of 0.6. 179 00:08:07,100 --> 00:08:10,130 It's the best one that works with Google Cardboard right now. 180 00:08:10,130 --> 00:08:12,820 So Cardboard SDK for Unity-- 181 00:08:12,820 --> 00:08:16,380 Unity Package-- is the one that you're going to want to install. 182 00:08:16,380 --> 00:08:18,060 It will upload everything. 183 00:08:18,060 --> 00:08:20,670 You can oftentimes select what types of things you want. 184 00:08:20,670 --> 00:08:22,590 For this, I'm just going to import it all. 185 00:08:22,590 --> 00:08:27,300 It shouldn't take any longer than usual and should be just fine like that. 186 00:08:27,300 --> 00:08:33,190 187 00:08:33,190 --> 00:08:36,429 So this is because we're using the old version of the SDK. 188 00:08:36,429 --> 00:08:38,409 And since this is a new project, normally 189 00:08:38,409 --> 00:08:40,841 if you had a project that had been built before, 190 00:08:40,841 --> 00:08:42,549 you'd really want to make a backup of it. 191 00:08:42,549 --> 00:08:44,350 Here, we don't exactly have a backup of it, 192 00:08:44,350 --> 00:08:47,740 but we don't care because it's a completely brand new project. 193 00:08:47,740 --> 00:08:52,870 So it will go ahead and basically run a script on all of the Google Cardboard 194 00:08:52,870 --> 00:08:58,000 scripts and update them to the new APIs and whatnot that Unity now uses. 195 00:08:58,000 --> 00:09:02,720 So you'll see that Cardboard and plug-ins show up here. 196 00:09:02,720 --> 00:09:06,430 And what we can do is go into Cardboard and Prefabs. 197 00:09:06,430 --> 00:09:09,460 Prefabs are like pre-made objects that can be downloaded. 198 00:09:09,460 --> 00:09:12,176 And so, for the pre-fab that we want-- 199 00:09:12,176 --> 00:09:13,300 it's called Cardboard Main. 200 00:09:13,300 --> 00:09:15,670 You'll see there's another Cardboard M here-- that's Manager. 201 00:09:15,670 --> 00:09:16,670 You don't want that. 202 00:09:16,670 --> 00:09:18,340 You want Cardboard Main. 203 00:09:18,340 --> 00:09:21,700 And this will make our app 3D. 204 00:09:21,700 --> 00:09:24,340 So you'll notice that since this part came down, 205 00:09:24,340 --> 00:09:26,980 you can now see that objects that we have in our world. 206 00:09:26,980 --> 00:09:31,150 We have some light source that's kind of showing up on the horizon here. 207 00:09:31,150 --> 00:09:33,220 And then we also have a main camera. 208 00:09:33,220 --> 00:09:36,370 And now we just dragged in Cardboard Main that just showed up. 209 00:09:36,370 --> 00:09:43,550 So if we run our app, it will switch over to the game tab and show 210 00:09:43,550 --> 00:09:44,630 something like this. 211 00:09:44,630 --> 00:09:46,120 You'll notice it's got weird stuff behind it. 212 00:09:46,120 --> 00:09:48,328 That's because I haven't deleted the main camera yet. 213 00:09:48,328 --> 00:09:51,100 So we can delete the main camera. 214 00:09:51,100 --> 00:09:53,397 And Cardboard Main will actually act like our camera 215 00:09:53,397 --> 00:09:55,480 and will be able to look around a virtual reality. 216 00:09:55,480 --> 00:09:59,500 So you can see that this is something like how the game will display 217 00:09:59,500 --> 00:10:01,000 once it's actually on your phone. 218 00:10:01,000 --> 00:10:02,890 Each side of those-- 219 00:10:02,890 --> 00:10:04,390 each side of the screen there-- 220 00:10:04,390 --> 00:10:08,260 what Google Cardboard does is it has two magnifying lenses that kind of help 221 00:10:08,260 --> 00:10:09,262 cross your eyes. 222 00:10:09,262 --> 00:10:12,220 And it uses the fact that when you cross your eyes with two things that 223 00:10:12,220 --> 00:10:15,860 are showing different perspectives, it makes it look really 3-D and real. 224 00:10:15,860 --> 00:10:19,390 So that's what this is displaying here. 225 00:10:19,390 --> 00:10:21,960 So that's how we know that Cardboard Main is working. 226 00:10:21,960 --> 00:10:24,000 If you already have some experience with Unity 227 00:10:24,000 --> 00:10:27,690 and you just have a world that you want to make into a 3-D virtual reality, 228 00:10:27,690 --> 00:10:29,490 you can literally drag Cardboard Main. 229 00:10:29,490 --> 00:10:32,310 And then whatever scripts you had on your camera, 230 00:10:32,310 --> 00:10:36,270 you pretty much just put them onto the Cardboard Main object and there you go. 231 00:10:36,270 --> 00:10:39,670 Now you've turned this other 3-D world into a 3-D virtual reality, 232 00:10:39,670 --> 00:10:43,330 which I think is pretty awesome and really easy to do. 233 00:10:43,330 --> 00:10:45,970 So now let's start actually building a world. 234 00:10:45,970 --> 00:10:49,420 We're going to add some terrain and make some mountains in here. 235 00:10:49,420 --> 00:10:51,890 So there are a couple of different ways you can do this. 236 00:10:51,890 --> 00:10:57,040 You can right click in the hierarchy and select 3-D object-- 237 00:10:57,040 --> 00:10:59,619 or maybe it's not 3-D object. 238 00:10:59,619 --> 00:11:00,160 I don't know. 239 00:11:00,160 --> 00:11:02,860 You can create stuff both in the hierarchy-- 240 00:11:02,860 --> 00:11:07,640 but the way that I normally do it, obviously, is to go through here. 241 00:11:07,640 --> 00:11:11,960 Looks like it is a 3-D object and it is on the terrain. 242 00:11:11,960 --> 00:11:13,560 So now we've got this terrain. 243 00:11:13,560 --> 00:11:15,530 You can see how big it is in the scene here. 244 00:11:15,530 --> 00:11:16,920 Let me back up. 245 00:11:16,920 --> 00:11:19,730 So now we've got a terrain. 246 00:11:19,730 --> 00:11:23,030 As big as it is, I like making mine a little bit bigger. 247 00:11:23,030 --> 00:11:24,311 So we're going to update this. 248 00:11:24,311 --> 00:11:26,810 You can see I clicked on the Settings panel for the terrain. 249 00:11:26,810 --> 00:11:28,460 We've got the terrain selected over here. 250 00:11:28,460 --> 00:11:30,210 And now I'm the inspector for the terrain. 251 00:11:30,210 --> 00:11:32,010 We've got settings for it. 252 00:11:32,010 --> 00:11:33,640 And I'm going to make it twice as big. 253 00:11:33,640 --> 00:11:37,391 So I'm going to adjust the width to be 1,000 and the height to be 1,000. 254 00:11:37,391 --> 00:11:39,140 And now you can see I've got twice as big. 255 00:11:39,140 --> 00:11:41,050 Awesome. 256 00:11:41,050 --> 00:11:44,650 And then you have to be careful if you're doing this on your own 257 00:11:44,650 --> 00:11:48,520 not to make it too big because it does a whole lot of calculations 258 00:11:48,520 --> 00:11:49,450 for the terrain. 259 00:11:49,450 --> 00:11:52,366 And if you make it too big, it can't do all those calculations at once 260 00:11:52,366 --> 00:11:54,370 and it will make your app run a lot slower 261 00:11:54,370 --> 00:11:56,560 or actually cause your app to completely break. 262 00:11:56,560 --> 00:12:00,064 So I find that 1,000 is pretty good for whatever you want to be doing. 263 00:12:00,064 --> 00:12:02,980 If you want to make bigger terrains, see whether or not your app still 264 00:12:02,980 --> 00:12:05,950 works with that gigantic terrain. 265 00:12:05,950 --> 00:12:08,080 Now we can actually draw some mountains on this. 266 00:12:08,080 --> 00:12:11,080 So there is a little raise and lower terrain button. 267 00:12:11,080 --> 00:12:14,500 I'm going to just view here so I'm seeing everything from the top. 268 00:12:14,500 --> 00:12:16,840 And then when you want to move around in your scene, 269 00:12:16,840 --> 00:12:19,890 these are your options up here in the corner. 270 00:12:19,890 --> 00:12:23,060 You can zoom in on these so you can see what's going on better. 271 00:12:23,060 --> 00:12:24,910 So these options up here in the corner are 272 00:12:24,910 --> 00:12:29,240 what you can use to actually move around in the world. 273 00:12:29,240 --> 00:12:32,940 So I'm going to do this and then zoom in. 274 00:12:32,940 --> 00:12:38,930 And since this is a programming course, of course we have to do-- 275 00:12:38,930 --> 00:12:40,080 hello, world. 276 00:12:40,080 --> 00:12:47,135 And so I will draw some mountains that spell out hello-- 277 00:12:47,135 --> 00:12:51,560 278 00:12:51,560 --> 00:12:53,222 oh, that's a of funky o-- 279 00:12:53,222 --> 00:12:55,940 and you'll note that I'm using my trackpad. 280 00:12:55,940 --> 00:12:58,610 A lot of this stuff can be easier with a mouse. 281 00:12:58,610 --> 00:13:02,360 But I happen to use a trackpad and it works just fine. 282 00:13:02,360 --> 00:13:03,560 So you can do either. 283 00:13:03,560 --> 00:13:08,570 284 00:13:08,570 --> 00:13:09,330 So there you go. 285 00:13:09,330 --> 00:13:10,320 It's just that easy. 286 00:13:10,320 --> 00:13:14,950 If you right click and move around, then you can change the orientation. 287 00:13:14,950 --> 00:13:20,080 And we can see that-- let's see, I'm going to move over here a little bit. 288 00:13:20,080 --> 00:13:24,190 And now we have some mountains that spell out, hello world. 289 00:13:24,190 --> 00:13:27,360 So you can kind of move back and forth in the mountains. 290 00:13:27,360 --> 00:13:30,810 So I think it's pretty easy how-- 291 00:13:30,810 --> 00:13:33,520 pretty cool how easy that is. 292 00:13:33,520 --> 00:13:36,115 So now we've created the terrain. 293 00:13:36,115 --> 00:13:37,990 The next thing that we're going to want to do 294 00:13:37,990 --> 00:13:41,150 is make a player that can move around the terrain. 295 00:13:41,150 --> 00:13:43,810 So here we are going to create a 3-D object. 296 00:13:43,810 --> 00:13:46,360 And this time it's going to be a sphere. 297 00:13:46,360 --> 00:13:49,540 What we could do at this point is make the camera, itself, 298 00:13:49,540 --> 00:13:51,080 what's moving around the world. 299 00:13:51,080 --> 00:13:54,670 But I find it much easier if we actually create a new object, the sphere, 300 00:13:54,670 --> 00:13:59,290 and put the camera inside of the sphere and have it move around that way. 301 00:13:59,290 --> 00:14:01,690 It makes a lot of the physical interactions easier 302 00:14:01,690 --> 00:14:04,720 and it's a lot easier to separate the programming that way. 303 00:14:04,720 --> 00:14:07,090 So I'm going to call this the player. 304 00:14:07,090 --> 00:14:09,840 305 00:14:09,840 --> 00:14:12,440 And what this is going to do is we're going 306 00:14:12,440 --> 00:14:18,200 to make this into an actual physical object in this world. 307 00:14:18,200 --> 00:14:22,370 So right now it's just going to kind of hover there. 308 00:14:22,370 --> 00:14:24,660 Let's see-- wow, that's very tiny. 309 00:14:24,660 --> 00:14:27,260 And it's kind of stuck in oblivion. 310 00:14:27,260 --> 00:14:28,820 That's extremely tiny. 311 00:14:28,820 --> 00:14:33,355 Anyhow, so in order to make this an actual physical object that 312 00:14:33,355 --> 00:14:36,230 can interact with the mountains, we need to add this component called 313 00:14:36,230 --> 00:14:37,840 the rigid body to it. 314 00:14:37,840 --> 00:14:39,310 So this is rigid body. 315 00:14:39,310 --> 00:14:42,100 And you literally just click on it and it adds a rigid body to it. 316 00:14:42,100 --> 00:14:45,520 You can see that this starts to look more like a physical object. 317 00:14:45,520 --> 00:14:49,990 It's got stuff like mass and drag and other things like that. 318 00:14:49,990 --> 00:14:53,190 So we can uncheck, Use Gravity, because we 319 00:14:53,190 --> 00:14:56,190 want this to be flying around the world and not just rolling. 320 00:14:56,190 --> 00:14:59,830 So that's what that does-- turns off gravity. 321 00:14:59,830 --> 00:15:01,920 And then, now it's time to actually make it fly. 322 00:15:01,920 --> 00:15:04,720 So this is the first programming part of this. 323 00:15:04,720 --> 00:15:06,399 I want to make a new script. 324 00:15:06,399 --> 00:15:08,940 So you'll see that that's an option down at the bottom here-- 325 00:15:08,940 --> 00:15:10,140 new script. 326 00:15:10,140 --> 00:15:12,820 And we're going to call it, Fly. 327 00:15:12,820 --> 00:15:15,130 And I happen to use the language C-sharp. 328 00:15:15,130 --> 00:15:16,420 You can also use JavaScript. 329 00:15:16,420 --> 00:15:18,190 But it looks quite a bit different. 330 00:15:18,190 --> 00:15:21,070 I happen to like C-sharp because it's a lot more like Java, 331 00:15:21,070 --> 00:15:22,390 which I know better. 332 00:15:22,390 --> 00:15:27,790 So if you double click on Fly, it should open up in some editor. 333 00:15:27,790 --> 00:15:30,910 For me, that's going to be the Monoscript editor. 334 00:15:30,910 --> 00:15:35,520 For other people, that can be something else, like Visual Studio 335 00:15:35,520 --> 00:15:39,700 or Monodevelop, not Monoscript. 336 00:15:39,700 --> 00:15:41,820 Where did it go? 337 00:15:41,820 --> 00:15:42,401 Hop up here? 338 00:15:42,401 --> 00:15:42,900 Yeah. 339 00:15:42,900 --> 00:15:43,399 OK. 340 00:15:43,399 --> 00:15:46,280 So it might open up in another window or you have to slide over. 341 00:15:46,280 --> 00:15:48,760 Time to make this into a new thing. 342 00:15:48,760 --> 00:15:55,630 OK, so you see that it starts us off with this Fly code here. 343 00:15:55,630 --> 00:16:00,220 And this is how every single script that you make is going to start off. 344 00:16:00,220 --> 00:16:02,050 Using-- you'll notice in C-sharp-- 345 00:16:02,050 --> 00:16:06,730 is a lot like Import and Python, where it just uses a particular library. 346 00:16:06,730 --> 00:16:09,400 Our script name is here, it's called Fly. 347 00:16:09,400 --> 00:16:12,407 And it actually subclasses another class called mono behavior. 348 00:16:12,407 --> 00:16:14,990 That's going to be the case for all of your different scripts. 349 00:16:14,990 --> 00:16:19,420 They're all going to be subclasses of mono behavior. 350 00:16:19,420 --> 00:16:22,330 Every single script can have a start and an update. 351 00:16:22,330 --> 00:16:25,720 This runs once at the start of when you're running your project. 352 00:16:25,720 --> 00:16:29,110 And then update this called once every single frame. 353 00:16:29,110 --> 00:16:31,420 And let's start to make this thing fly. 354 00:16:31,420 --> 00:16:36,580 So it seems obvious that we'll probably want a type of speed for the ball. 355 00:16:36,580 --> 00:16:38,750 So we'll have a float speed. 356 00:16:38,750 --> 00:16:42,070 And if we want things to be editable inside of the Unity editor, 357 00:16:42,070 --> 00:16:44,150 we can label them public. 358 00:16:44,150 --> 00:16:46,640 And then we can edit them as we go and adjust them. 359 00:16:46,640 --> 00:16:48,850 So almost all of the-- 360 00:16:48,850 --> 00:16:51,314 almost, if not all, of the variables we use 361 00:16:51,314 --> 00:16:53,980 will be public variables so that we can edit them in the editor. 362 00:16:53,980 --> 00:16:59,320 363 00:16:59,320 --> 00:17:01,570 And then, as well as speed, we're also going 364 00:17:01,570 --> 00:17:04,619 to need the pointer that we want the object to go. 365 00:17:04,619 --> 00:17:06,910 So if we want to go this way, we need to have something 366 00:17:06,910 --> 00:17:09,349 for it to point to tell it what direction to go. 367 00:17:09,349 --> 00:17:14,140 So this is actually going to be a game object that we'll give it. 368 00:17:14,140 --> 00:17:17,990 And game objects are really any type of object that we see in that hierarchy. 369 00:17:17,990 --> 00:17:21,910 So the ball itself is a game object, as well as Cardboard Main. 370 00:17:21,910 --> 00:17:25,599 And, as we'll see, a particular part of Cardboard Main called, 371 00:17:25,599 --> 00:17:27,310 Head, is also a game object. 372 00:17:27,310 --> 00:17:30,470 And that's what we're really using as the pointer here. 373 00:17:30,470 --> 00:17:32,980 So we have the speed, we have the pointer, 374 00:17:32,980 --> 00:17:35,950 and now instead of actually using start an update, 375 00:17:35,950 --> 00:17:39,160 I'm going to be using this one called-- 376 00:17:39,160 --> 00:17:41,101 what is it called-- 377 00:17:41,101 --> 00:17:42,290 is that the right one? 378 00:17:42,290 --> 00:17:42,790 Yes. 379 00:17:42,790 --> 00:17:43,331 Fixed update. 380 00:17:43,331 --> 00:17:50,160 381 00:17:50,160 --> 00:17:52,620 So fixed update is what Unity likes to use 382 00:17:52,620 --> 00:17:57,821 whenever you're adjusting the physical properties or, like, how something 383 00:17:57,821 --> 00:17:58,320 is moving. 384 00:17:58,320 --> 00:18:01,930 So in this case, we want to be adjusting the velocity of the object. 385 00:18:01,930 --> 00:18:04,760 And so you want to do that inside fixed update, not update. 386 00:18:04,760 --> 00:18:07,140 So any physics type stuff you're generally 387 00:18:07,140 --> 00:18:10,820 going to want to do in fixed update. 388 00:18:10,820 --> 00:18:16,300 So now we actually want to get the rigid body component of the ball. 389 00:18:16,300 --> 00:18:20,860 So we'll do that with rigid body kit component. 390 00:18:20,860 --> 00:18:27,100 And then we want rigid body. 391 00:18:27,100 --> 00:18:32,050 So this literally just accesses the rigid body component of ball 392 00:18:32,050 --> 00:18:37,540 that we've made and assigns it to the variable RB, short for rigid body. 393 00:18:37,540 --> 00:18:41,580 And now we can use this rigid body to actually move the object. 394 00:18:41,580 --> 00:18:51,460 So we can say RB.velocity is equal to speed times pointer. 395 00:18:51,460 --> 00:18:55,060 So you'll notice that we just accessed the pointer here. 396 00:18:55,060 --> 00:18:58,210 And then it-- every single game object has 397 00:18:58,210 --> 00:19:00,510 a component of it called the transform. 398 00:19:00,510 --> 00:19:02,260 And I'm actually going to switch over here 399 00:19:02,260 --> 00:19:05,600 so you can see what this transform looks like. 400 00:19:05,600 --> 00:19:08,350 So here you'll notice our player has a transform right here. 401 00:19:08,350 --> 00:19:11,200 The transfer arm holds things like position, rotation, and scale. 402 00:19:11,200 --> 00:19:13,120 But it also holds the different direction. 403 00:19:13,120 --> 00:19:18,010 So it just so happens that there's a forward vector that we can reference. 404 00:19:18,010 --> 00:19:20,720 And so that's what we're going to do back in the code. 405 00:19:20,720 --> 00:19:28,170 So here, transform.forward and that will get the blue axis of the transform 406 00:19:28,170 --> 00:19:31,780 in the world space, which is the forward axis. 407 00:19:31,780 --> 00:19:34,360 So this will set the velocity of the ball to be the speed. 408 00:19:34,360 --> 00:19:37,050 And then whatever object is pointing in a certain direction, 409 00:19:37,050 --> 00:19:39,240 it will point in the same direction as that object 410 00:19:39,240 --> 00:19:40,950 and move forward in that direction. 411 00:19:40,950 --> 00:19:42,340 That's exactly what we want. 412 00:19:42,340 --> 00:19:43,710 So we can save this. 413 00:19:43,710 --> 00:19:50,070 And then as we switch back into Unity, we notice that this will update. 414 00:19:50,070 --> 00:19:54,300 And now it has options for us to put in a speed and a pointer. 415 00:19:54,300 --> 00:19:59,560 So speed works off well as 10-- just to start off-- to see how things go. 416 00:19:59,560 --> 00:20:02,970 And then for the pointer, we actually want 417 00:20:02,970 --> 00:20:07,060 this to be the head underneath Cardboard Main. 418 00:20:07,060 --> 00:20:10,770 So a note about the differences between Cardboard Main and Head. 419 00:20:10,770 --> 00:20:14,147 Head is going to be the rotation of the user when they're moving around. 420 00:20:14,147 --> 00:20:16,980 So when they look through Google Cardboard and they move their head, 421 00:20:16,980 --> 00:20:18,630 that's going to be what's rotating. 422 00:20:18,630 --> 00:20:23,160 Cardboard Main is going to be the entire camera moving around in the space. 423 00:20:23,160 --> 00:20:25,660 So if you have any movement scripts that you want to attach, 424 00:20:25,660 --> 00:20:27,701 those are going to be attached to Cardboard Main. 425 00:20:27,701 --> 00:20:30,420 If you ever want to see what direction a person is looking in, 426 00:20:30,420 --> 00:20:33,540 that's going to be the forward vector on the head. 427 00:20:33,540 --> 00:20:37,440 So since we want the player to move in the direction that they're looking, 428 00:20:37,440 --> 00:20:39,630 we'll just drag the head object in to there 429 00:20:39,630 --> 00:20:41,459 and that should allow the ball to move. 430 00:20:41,459 --> 00:20:43,875 I'm going to make sure that the ball starts off at 0, 0, 0 431 00:20:43,875 --> 00:20:47,150 so we can actually see it. 432 00:20:47,150 --> 00:20:54,260 And when we play, you can see the ball flying off. 433 00:20:54,260 --> 00:20:59,920 And then a little intro into how to actually use the emulator on here. 434 00:20:59,920 --> 00:21:01,220 So I'll play it again. 435 00:21:01,220 --> 00:21:03,662 If you hold down Option, and you move your mouse around, 436 00:21:03,662 --> 00:21:05,870 it allows you to look around in different directions. 437 00:21:05,870 --> 00:21:08,911 And we can see that the ball is moving around in the different directions 438 00:21:08,911 --> 00:21:10,850 that we look-- up and down and around. 439 00:21:10,850 --> 00:21:12,950 And then if you hold down Control, you can tilt. 440 00:21:12,950 --> 00:21:16,199 This won't do anything because it's not actually affecting the forward vector. 441 00:21:16,199 --> 00:21:18,134 But it allows you to move around in the world. 442 00:21:18,134 --> 00:21:20,300 So you'll notice that this is still showing like how 443 00:21:20,300 --> 00:21:22,550 it would display on your phone. 444 00:21:22,550 --> 00:21:26,480 Cardboard Main actually has a couple options to help deal with that. 445 00:21:26,480 --> 00:21:29,330 So VR mode enabled here actually allows it 446 00:21:29,330 --> 00:21:32,940 so that you can just see your world without having that VR stuff. 447 00:21:32,940 --> 00:21:36,140 You're going to make sure that you recheck that though before you actually 448 00:21:36,140 --> 00:21:38,150 export or build your app because otherwise 449 00:21:38,150 --> 00:21:39,920 it will display on your phone like this. 450 00:21:39,920 --> 00:21:41,780 If you don't have Google Cardboard yet, it 451 00:21:41,780 --> 00:21:45,012 might actually be a good idea to export it with this unchecked. 452 00:21:45,012 --> 00:21:46,970 So that way it displays on your phone like this 453 00:21:46,970 --> 00:21:48,500 and you can just look around and see stuff. 454 00:21:48,500 --> 00:21:50,458 If you have Google Cardboard, you're definitely 455 00:21:50,458 --> 00:21:54,921 going to want to have that check so it actually makes a virtual reality. 456 00:21:54,921 --> 00:21:56,420 All right, so that's the first test. 457 00:21:56,420 --> 00:22:00,290 We now have a ball that can fly around the world. 458 00:22:00,290 --> 00:22:04,071 Now we just have to attach the Cardboard Main to the ball 459 00:22:04,071 --> 00:22:07,070 and actually be inside of it so that you feel like you're the one flying 460 00:22:07,070 --> 00:22:08,550 as you go through the app. 461 00:22:08,550 --> 00:22:11,750 So the way that we're going to do that is a pretty simple script-- 462 00:22:11,750 --> 00:22:15,980 we're just going to call it Follow, and make a new script. 463 00:22:15,980 --> 00:22:20,450 And this is literally going to follow the player object. 464 00:22:20,450 --> 00:22:22,100 So we'll give it a target. 465 00:22:22,100 --> 00:22:32,740 466 00:22:32,740 --> 00:22:36,940 And then here, again, we're not going to be using Start or Update. 467 00:22:36,940 --> 00:22:39,880 We're going to be using another one called Late Update. 468 00:22:39,880 --> 00:22:44,620 So the reason for this, is that all of the physical actions 469 00:22:44,620 --> 00:22:48,890 take place around this update time and around this, like, fixed update. 470 00:22:48,890 --> 00:22:51,550 And what I want to have happen is I want the ball to move 471 00:22:51,550 --> 00:22:53,800 and then I want the camera to move inside of it. 472 00:22:53,800 --> 00:22:55,721 If we have a situation where the camera moves 473 00:22:55,721 --> 00:22:57,970 to where the ball is, and then the ball jumps forward, 474 00:22:57,970 --> 00:23:00,494 it could be that our camera actually is outside 475 00:23:00,494 --> 00:23:02,410 of the ball by the time the frame is finished. 476 00:23:02,410 --> 00:23:04,450 And then we'll like see the ball hovering in front of us 477 00:23:04,450 --> 00:23:05,658 and it will be kind of weird. 478 00:23:05,658 --> 00:23:08,380 A note as still like how this all works-- 479 00:23:08,380 --> 00:23:11,540 Unity only renders the outsides of objects. 480 00:23:11,540 --> 00:23:13,677 So if we put the camera inside of the sphere, 481 00:23:13,677 --> 00:23:15,760 we'll actually be able to look out from the sphere 482 00:23:15,760 --> 00:23:17,890 and won't just see like the outside edge or feel 483 00:23:17,890 --> 00:23:19,510 like we're trapped inside this bubble. 484 00:23:19,510 --> 00:23:22,460 And we'll see a better example of this later, but that's how this works. 485 00:23:22,460 --> 00:23:24,376 So if you put something inside something else, 486 00:23:24,376 --> 00:23:26,250 you can always see outside of the object. 487 00:23:26,250 --> 00:23:28,570 You just can't see into it. 488 00:23:28,570 --> 00:23:32,890 So inside of this Late Update we're going to reference the current object 489 00:23:32,890 --> 00:23:33,910 that the script is on. 490 00:23:33,910 --> 00:23:36,610 So we're going to want to put this onto Cardboard Main. 491 00:23:36,610 --> 00:23:38,590 Game Object it's kind of like Self in Python. 492 00:23:38,590 --> 00:23:42,520 It just references what other current object that the script is on. 493 00:23:42,520 --> 00:23:47,140 So Game Object we want to access this one as transformed-- so it's position. 494 00:23:47,140 --> 00:23:51,510 And so its position equal to whatever the target transference position is. 495 00:23:51,510 --> 00:23:56,870 Target dot transform-- and then position. 496 00:23:56,870 --> 00:23:58,430 Ta-da, not too hard. 497 00:23:58,430 --> 00:24:01,570 So as we switch back over to Unity-- 498 00:24:01,570 --> 00:24:02,820 eventually this should update. 499 00:24:02,820 --> 00:24:06,810 I oftentimes like to hit Pause just to force it to update to whatever script 500 00:24:06,810 --> 00:24:08,870 we made. 501 00:24:08,870 --> 00:24:11,420 And now you can see that that shows up. 502 00:24:11,420 --> 00:24:15,630 And inside that target, we're going to want to put the player. 503 00:24:15,630 --> 00:24:17,040 So you can actually drag it. 504 00:24:17,040 --> 00:24:19,150 You notice each time that we drag, there's 505 00:24:19,150 --> 00:24:20,900 also a little button over here-- 506 00:24:20,900 --> 00:24:24,480 I'll zoom in so that you can see it better. 507 00:24:24,480 --> 00:24:26,220 So there's this little button here. 508 00:24:26,220 --> 00:24:28,400 And if you click that, then another window 509 00:24:28,400 --> 00:24:32,294 opens up where you can select from all of the different possible objects. 510 00:24:32,294 --> 00:24:34,460 So if you don't like dragging, that's another option 511 00:24:34,460 --> 00:24:35,750 where you can just select it. 512 00:24:35,750 --> 00:24:39,300 So now it's inside of our player, and we should 513 00:24:39,300 --> 00:24:43,830 be able to move around and actually do our first test of actually 514 00:24:43,830 --> 00:24:46,330 being inside of the sphere. 515 00:24:46,330 --> 00:24:49,950 So it turns out that the way that we are moving the player before 516 00:24:49,950 --> 00:24:55,470 was a little bit too slow, so we're going to switch this up to speed of 50. 517 00:24:55,470 --> 00:24:57,400 And then we're going to play it. 518 00:24:57,400 --> 00:25:02,809 519 00:25:02,809 --> 00:25:05,100 So now, for the first time, you can see we are actually 520 00:25:05,100 --> 00:25:07,470 flying around this virtual world. 521 00:25:07,470 --> 00:25:12,270 And we can kind of dip and dive in between mountains and fly around. 522 00:25:12,270 --> 00:25:16,100 And I love doing this because its so much fun to fly around mountains. 523 00:25:16,100 --> 00:25:19,240 So in virtual reality, it will look very similar to this, 524 00:25:19,240 --> 00:25:22,740 except it will actually look 3-D. And if you put it on your phone, 525 00:25:22,740 --> 00:25:25,290 and you don't have the virtual reality in it enabled-- 526 00:25:25,290 --> 00:25:26,706 so you like uncheck that box-- 527 00:25:26,706 --> 00:25:29,580 then it will show up like this and you'll just move your phone around 528 00:25:29,580 --> 00:25:32,010 and it will display differently based on which direction your phone is 529 00:25:32,010 --> 00:25:32,640 pointed in. 530 00:25:32,640 --> 00:25:34,200 So both are pretty cool effects. 531 00:25:34,200 --> 00:25:37,840 532 00:25:37,840 --> 00:25:40,870 So now that we've actually got a working prototype for how 533 00:25:40,870 --> 00:25:42,940 we want this app to work, it's a good time 534 00:25:42,940 --> 00:25:46,090 to organize this project workspace down here. 535 00:25:46,090 --> 00:25:49,670 So I like to organize everything by its particular type. 536 00:25:49,670 --> 00:25:53,290 So I'm going to make a scripts folder for all of the scripts 537 00:25:53,290 --> 00:25:54,630 and put those in there. 538 00:25:54,630 --> 00:25:57,140 539 00:25:57,140 --> 00:26:01,617 And Google Cardboard looks like it also has a plug-ins folder, 540 00:26:01,617 --> 00:26:02,700 as well, that is imported. 541 00:26:02,700 --> 00:26:08,870 So we can put all of Google Cardboard into one folder. 542 00:26:08,870 --> 00:26:12,780 Plug-ins and cardboard into Google Cardboard. 543 00:26:12,780 --> 00:26:17,730 Rearranging stuff in here won't affect how your project runs at all. 544 00:26:17,730 --> 00:26:20,260 It will find all the same assets in the same spot. 545 00:26:20,260 --> 00:26:22,570 I also notice that I haven't really named the terrain. 546 00:26:22,570 --> 00:26:26,160 So I can call this mountains. 547 00:26:26,160 --> 00:26:28,050 And make sure you hit Enter. 548 00:26:28,050 --> 00:26:30,090 If you don't, it might not update and then 549 00:26:30,090 --> 00:26:32,100 you'll have to re-type in the name. 550 00:26:32,100 --> 00:26:42,260 And I'm also going to call this mountain terrain and make a new [INAUDIBLE] 551 00:26:42,260 --> 00:26:44,480 folder. 552 00:26:44,480 --> 00:26:49,430 So the main reason for organizing stuff is so that it's easy to find later. 553 00:26:49,430 --> 00:26:51,580 And if you make a lot of projects, maybe you 554 00:26:51,580 --> 00:26:54,670 want to copy this script over onto a different project. 555 00:26:54,670 --> 00:26:57,550 And it's really easy if you know where your scripts folder is. 556 00:26:57,550 --> 00:27:01,330 I know this is a lot unlike my room, because my room is very, very messy. 557 00:27:01,330 --> 00:27:03,900 But I like to happen to like to keep my work spaces clean. 558 00:27:03,900 --> 00:27:08,040 So that's that. 559 00:27:08,040 --> 00:27:12,710 Now we're going to make a whole bunch of improvements on this world. 560 00:27:12,710 --> 00:27:17,330 I think it's really fun to paint the mountains and change their textures, 561 00:27:17,330 --> 00:27:18,710 and so we'll look into that. 562 00:27:18,710 --> 00:27:21,440 We'll also be able to add some objects into this world 563 00:27:21,440 --> 00:27:25,490 that you can find online and we'll do some more programming. 564 00:27:25,490 --> 00:27:28,850 I want to show a bug that's in the program right now. 565 00:27:28,850 --> 00:27:33,080 As we sort of fly, I didn't actually try to fly through any mountains, 566 00:27:33,080 --> 00:27:36,117 but you'll notice that if we try to, sometimes 567 00:27:36,117 --> 00:27:37,700 we'll actually bump into the mountain. 568 00:27:37,700 --> 00:27:41,780 A lot of time, we'll kind of like jerk through it and it will act very weird. 569 00:27:41,780 --> 00:27:44,840 So we're going to spend some programming time going through that 570 00:27:44,840 --> 00:27:47,300 and figuring out different methods of dealing with that. 571 00:27:47,300 --> 00:27:49,500 So Unity isn't completely perfect all the time. 572 00:27:49,500 --> 00:27:52,519 And oftentimes, you have to find ways to get around ways that it's not 573 00:27:52,519 --> 00:27:53,310 absolutely perfect. 574 00:27:53,310 --> 00:27:56,290 575 00:27:56,290 --> 00:27:57,555 So the first thing-- textures. 576 00:27:57,555 --> 00:28:00,230 577 00:28:00,230 --> 00:28:03,500 Textures are what allow objects to look differently. 578 00:28:03,500 --> 00:28:08,180 And so, as we go through, we'll be able to actually-- instead of just having 579 00:28:08,180 --> 00:28:10,129 this plain, vanilla-like white background, 580 00:28:10,129 --> 00:28:12,170 we can change how the mountains look and actually 581 00:28:12,170 --> 00:28:14,750 get them to look a heck of a lot more like mountains. 582 00:28:14,750 --> 00:28:17,550 These textures can be any PNG image. 583 00:28:17,550 --> 00:28:20,060 So if you have, like, a photo of your friend 584 00:28:20,060 --> 00:28:23,210 that you want to use as how you want your mountains to look, 585 00:28:23,210 --> 00:28:26,450 you can actually copy paste the photo of your friend onto here. 586 00:28:26,450 --> 00:28:28,280 That will look pretty flat. 587 00:28:28,280 --> 00:28:31,040 One thing that all of the PNGs are is they're static, 588 00:28:31,040 --> 00:28:34,250 so you can't have, like, moving images on there. 589 00:28:34,250 --> 00:28:36,170 I tried to look up a little bit yesterday 590 00:28:36,170 --> 00:28:37,840 at how you could do moving images. 591 00:28:37,840 --> 00:28:40,640 It looks like it's fairly complicated and that Unity isn't especially suited 592 00:28:40,640 --> 00:28:41,140 to it. 593 00:28:41,140 --> 00:28:43,710 But you might be able to if you wanted to. 594 00:28:43,710 --> 00:28:46,370 Most of textures though, are going to be completely static. 595 00:28:46,370 --> 00:28:51,110 You can make them look a lot more 3-D though with a special normal PNG. 596 00:28:51,110 --> 00:28:56,300 And so it'll look kind of funky, but it will allow you to have a flat area 597 00:28:56,300 --> 00:28:59,540 and then show a 3-D texture on top of it. 598 00:28:59,540 --> 00:29:02,056 So I'll explain that more when we get there. 599 00:29:02,056 --> 00:29:04,430 The coolest thing about textures is that you can actually 600 00:29:04,430 --> 00:29:05,750 download them from online. 601 00:29:05,750 --> 00:29:10,450 So we're going to show you guys the asset store here. 602 00:29:10,450 --> 00:29:12,000 And it takes a second to load. 603 00:29:12,000 --> 00:29:15,580 It's pretty cool because it has a lot of free stuff that you can get. 604 00:29:15,580 --> 00:29:18,150 And it's right here inside of Unity. 605 00:29:18,150 --> 00:29:22,367 Looks like it didn't quite load correctly, so I'll reload it. 606 00:29:22,367 --> 00:29:23,950 Hopefully it will come up right-- yay. 607 00:29:23,950 --> 00:29:26,650 OK, so in this case, we're looking for textures. 608 00:29:26,650 --> 00:29:28,400 So I'm going to search for a texture pack. 609 00:29:28,400 --> 00:29:30,930 610 00:29:30,930 --> 00:29:32,820 And I only want free texture packs because I 611 00:29:32,820 --> 00:29:34,710 don't feel like spending money. 612 00:29:34,710 --> 00:29:37,749 And this one looks pretty good. 613 00:29:37,749 --> 00:29:39,790 So for you guys, this will probably say download. 614 00:29:39,790 --> 00:29:44,480 It just so happens that I've already downloaded it so I can just import it. 615 00:29:44,480 --> 00:29:48,306 And this will show up similar to when we imported our SDK as a package. 616 00:29:48,306 --> 00:29:50,180 It will show, like, a little list of objects. 617 00:29:50,180 --> 00:29:53,090 For these ones, I highly recommend selecting everything 618 00:29:53,090 --> 00:29:54,330 that you don't need. 619 00:29:54,330 --> 00:29:58,220 Here-- there is a lot of stuff that we really don't need in it. 620 00:29:58,220 --> 00:30:00,470 And so the things that I want are actually 621 00:30:00,470 --> 00:30:04,642 just these particular cave rock wall images. 622 00:30:04,642 --> 00:30:07,100 You can see that that's what that one's going to look like. 623 00:30:07,100 --> 00:30:08,499 This is a different color. 624 00:30:08,499 --> 00:30:10,040 And this is what a normal looks like. 625 00:30:10,040 --> 00:30:14,570 So it's kind of got like this funky purple, like, blue sheen to it. 626 00:30:14,570 --> 00:30:18,740 And that's what's going to make errors actually look 3-D. 627 00:30:18,740 --> 00:30:21,470 And then I also like having this darker one, as well. 628 00:30:21,470 --> 00:30:22,550 So we can import these. 629 00:30:22,550 --> 00:30:26,330 630 00:30:26,330 --> 00:30:29,512 And this will show up in our project plane. 631 00:30:29,512 --> 00:30:31,220 Just so happens that it already puts them 632 00:30:31,220 --> 00:30:33,800 in a textures folder, which I really like, 633 00:30:33,800 --> 00:30:36,580 so I don't have to organize anything. 634 00:30:36,580 --> 00:30:39,220 And now we can start to paint our mountains. 635 00:30:39,220 --> 00:30:42,964 So we'll go into the scene here, click on our mountains. 636 00:30:42,964 --> 00:30:45,380 And you'll notice that there is a little paint brush here. 637 00:30:45,380 --> 00:30:48,171 And this is what allows us to paint our mountains different colors. 638 00:30:48,171 --> 00:30:49,610 So we can edit the textures. 639 00:30:49,610 --> 00:30:52,570 Add a particular texture. 640 00:30:52,570 --> 00:30:55,920 And your texture options-- 641 00:30:55,920 --> 00:30:59,340 if we want to select a particular one, we 642 00:30:59,340 --> 00:31:01,260 can select it here, or of course drag. 643 00:31:01,260 --> 00:31:04,520 644 00:31:04,520 --> 00:31:05,290 It's interesting. 645 00:31:05,290 --> 00:31:08,140 Normally this image would also be displayed here. 646 00:31:08,140 --> 00:31:11,830 So something's going a little bit wrong, but hopefully this will still work. 647 00:31:11,830 --> 00:31:13,780 Yep, it still displays there just fine. 648 00:31:13,780 --> 00:31:16,030 So, you know, Unity can be a little bit finicky. 649 00:31:16,030 --> 00:31:18,970 But as long as things seem to be working, they'll generally work. 650 00:31:18,970 --> 00:31:21,460 So here, now we can add that to here. 651 00:31:21,460 --> 00:31:26,940 And you can see that our mountains just got looking a lot more like mountains. 652 00:31:26,940 --> 00:31:28,690 So if we fly around the world now, you can 653 00:31:28,690 --> 00:31:33,890 see that they look like this when you get up close and it looks pretty cool. 654 00:31:33,890 --> 00:31:35,530 So I'm going to back up. 655 00:31:35,530 --> 00:31:39,130 And I don't want it all to be gray. 656 00:31:39,130 --> 00:31:41,010 So I'm going to add a new texture. 657 00:31:41,010 --> 00:31:43,890 And we'll make this one a little bit lighter. 658 00:31:43,890 --> 00:31:47,150 659 00:31:47,150 --> 00:31:50,940 And then we can actually, literally, just paint in our world. 660 00:31:50,940 --> 00:31:54,830 And I want to use a slightly bigger one so we can cover all of the mountains. 661 00:31:54,830 --> 00:32:00,630 And then I want to switch the white one and paint world. 662 00:32:00,630 --> 00:32:07,010 663 00:32:07,010 --> 00:32:11,540 And then, as we fly around, we will see that some of the mountains 664 00:32:11,540 --> 00:32:12,792 are going to be lighter. 665 00:32:12,792 --> 00:32:14,750 And then some of the other ones will be darker. 666 00:32:14,750 --> 00:32:15,830 So we can hit play. 667 00:32:15,830 --> 00:32:19,070 668 00:32:19,070 --> 00:32:21,660 They'll fly around our world and see that there are some 669 00:32:21,660 --> 00:32:24,090 that look like snow has fallen on them. 670 00:32:24,090 --> 00:32:26,690 So there's a whole lot of cool stuff you can do with textures. 671 00:32:26,690 --> 00:32:29,190 And one of the things that I really want to experiment with, 672 00:32:29,190 --> 00:32:32,910 and I hope you guys will, is if you have more metallic textures, 673 00:32:32,910 --> 00:32:35,070 and you can mix them with, like, natural textures, 674 00:32:35,070 --> 00:32:37,950 and make a whole bunch of, like, really funky scenes that kind 675 00:32:37,950 --> 00:32:41,340 of border in between natural and metallic and man-made. 676 00:32:41,340 --> 00:32:44,904 And so I think that would be a super cool thing to do. 677 00:32:44,904 --> 00:32:46,320 I'm running through the mountains. 678 00:32:46,320 --> 00:32:47,307 OK. 679 00:32:47,307 --> 00:32:48,140 So we can stop that. 680 00:32:48,140 --> 00:32:51,110 681 00:32:51,110 --> 00:32:53,950 So now we've done our painting of the mountains 682 00:32:53,950 --> 00:32:56,510 and gotten things to look a little bit differently. 683 00:32:56,510 --> 00:32:59,300 Let's see what happens if we want to add an object. 684 00:32:59,300 --> 00:33:05,980 So it just so happens that Unity is able to display these fbx or .fbx or film 685 00:33:05,980 --> 00:33:07,696 box objects. 686 00:33:07,696 --> 00:33:09,820 And there are a lot of these online because they're 687 00:33:09,820 --> 00:33:12,080 used, oftentimes, for 3-D modeling. 688 00:33:12,080 --> 00:33:13,960 And I asked my roommate so like, what do you 689 00:33:13,960 --> 00:33:15,740 think would be a cool thing to add to this world? 690 00:33:15,740 --> 00:33:18,850 And he said, oh, that looks pretty cool, but I'd like to add a fortress. 691 00:33:18,850 --> 00:33:21,910 So I literally went to Google and-- 692 00:33:21,910 --> 00:33:23,650 see if I can get out of this-- 693 00:33:23,650 --> 00:33:28,760 and typed in fortressfbx-- 694 00:33:28,760 --> 00:33:33,080 and hey, what do you know, they have a three fortress fbx model 695 00:33:33,080 --> 00:33:36,770 we can click on and download. 696 00:33:36,770 --> 00:33:37,630 Looks like this. 697 00:33:37,630 --> 00:33:40,494 698 00:33:40,494 --> 00:33:42,910 And you can download it right there and it should give you 699 00:33:42,910 --> 00:33:44,776 an option to select it as an fbx. 700 00:33:44,776 --> 00:33:46,900 It just so happens that I've already downloaded it. 701 00:33:46,900 --> 00:33:49,270 So I'm going to now install it in my projects. 702 00:33:49,270 --> 00:33:53,710 Just going to switch a couple slides here as I get back to my main screen. 703 00:33:53,710 --> 00:33:54,430 All right. 704 00:33:54,430 --> 00:33:57,020 So here's my desktop. 705 00:33:57,020 --> 00:33:58,420 I'm going to open up Finder. 706 00:33:58,420 --> 00:34:00,550 And I just happened to-- when I downloaded that-- 707 00:34:00,550 --> 00:34:03,490 I happened to not save it My Downloads folder, but instead 708 00:34:03,490 --> 00:34:07,870 into this Resources folder. 709 00:34:07,870 --> 00:34:11,250 And so the castle is right here. 710 00:34:11,250 --> 00:34:13,199 Remember when at the start of-- 711 00:34:13,199 --> 00:34:16,710 when I made my project, I named it CS50 Seminar VR World. 712 00:34:16,710 --> 00:34:21,860 So we actually can just copy this castle folder 713 00:34:21,860 --> 00:34:25,600 and paste it into the Assets folder of our project. 714 00:34:25,600 --> 00:34:29,040 715 00:34:29,040 --> 00:34:33,080 Oh, did I say new folder instead of paste. 716 00:34:33,080 --> 00:34:35,000 Pasted on. 717 00:34:35,000 --> 00:34:36,170 It will show up there. 718 00:34:36,170 --> 00:34:43,600 And then as we go back to Unity, you'll see that Unity starts to update. 719 00:34:43,600 --> 00:34:46,311 And if we click on Assets after it's done updating, 720 00:34:46,311 --> 00:34:48,810 we'll see that there is a castle folder inside of there that 721 00:34:48,810 --> 00:34:52,900 will actually hold this castle object. 722 00:34:52,900 --> 00:34:55,650 So here is the castle fbx right here. 723 00:34:55,650 --> 00:35:01,150 We can just drag this onto the scene. 724 00:35:01,150 --> 00:35:03,010 Looks like it's super tiny right now. 725 00:35:03,010 --> 00:35:05,170 So let's make it a little bit bigger. 726 00:35:05,170 --> 00:35:06,630 How about 500 times bigger? 727 00:35:06,630 --> 00:35:11,420 728 00:35:11,420 --> 00:35:12,350 There we go. 729 00:35:12,350 --> 00:35:16,720 And then let's rotate it so that fits on the ground better. 730 00:35:16,720 --> 00:35:19,060 And I happen to know that I want it facing this way 731 00:35:19,060 --> 00:35:21,730 direction because I know that the person's going 732 00:35:21,730 --> 00:35:23,275 to be starting off in this corner. 733 00:35:23,275 --> 00:35:26,150 So I actually want them to face the castle as they go into the world. 734 00:35:26,150 --> 00:35:27,941 That's why I did negative 90 instead of 90, 735 00:35:27,941 --> 00:35:30,170 because 90 would have flipped it the other way. 736 00:35:30,170 --> 00:35:32,350 So we now have this castle in our world. 737 00:35:32,350 --> 00:35:38,850 And if we press play, and we turn around-- 738 00:35:38,850 --> 00:35:40,040 hey, what do you know? 739 00:35:40,040 --> 00:35:42,460 We have a castle. 740 00:35:42,460 --> 00:35:44,750 One potential issue with this castle, though, 741 00:35:44,750 --> 00:35:48,610 is that it doesn't have any of these things called colliders on it. 742 00:35:48,610 --> 00:35:51,610 So the mountains happen to have built-in colliders, 743 00:35:51,610 --> 00:35:55,340 as do the sphere that we have the camera on right now. 744 00:35:55,340 --> 00:35:57,590 And it makes it so that sometimes you bump into stuff. 745 00:35:57,590 --> 00:35:59,381 I mentioned that there are issues with this 746 00:35:59,381 --> 00:36:01,180 that we'll fix with programming soon. 747 00:36:01,180 --> 00:36:03,880 But the castle has no colliders, so we can literally 748 00:36:03,880 --> 00:36:08,590 fly through walls and doors and things like that without any issue whatsoever. 749 00:36:08,590 --> 00:36:10,240 And it looks really weird like that. 750 00:36:10,240 --> 00:36:14,450 So let's back up and fix that. 751 00:36:14,450 --> 00:36:17,210 I literally discovered this yesterday while I 752 00:36:17,210 --> 00:36:19,267 was making this presentation because-- 753 00:36:19,267 --> 00:36:21,350 and it would have saved me a heck of a lot of time 754 00:36:21,350 --> 00:36:24,070 while I was making a project last year. 755 00:36:24,070 --> 00:36:28,900 It just so happens that under the castle fbx-- 756 00:36:28,900 --> 00:36:30,050 object down in here. 757 00:36:30,050 --> 00:36:33,190 So you have to actually click on it inside of the Project tab. 758 00:36:33,190 --> 00:36:35,770 There's an option called Generate Colliders. 759 00:36:35,770 --> 00:36:41,727 And this creates colliders that will then make it so that our ball does not 760 00:36:41,727 --> 00:36:43,060 run through the different walls. 761 00:36:43,060 --> 00:36:46,900 So for now if we turn and try to run through a wall, 762 00:36:46,900 --> 00:36:49,210 sometimes this works better than other times, 763 00:36:49,210 --> 00:36:51,610 because again, Unity is not working great. 764 00:36:51,610 --> 00:36:55,030 But we can-- maybe it will stop us. 765 00:36:55,030 --> 00:36:57,610 Maybe-- yeah, this time it actually stopped us and we now 766 00:36:57,610 --> 00:36:58,870 are running into the wall. 767 00:36:58,870 --> 00:37:01,470 So you can see that Unity still isn't rendering it perfectly, 768 00:37:01,470 --> 00:37:03,889 but hey, at least it got a little bit better. 769 00:37:03,889 --> 00:37:05,430 And we can see the collider is there. 770 00:37:05,430 --> 00:37:08,910 If we hadn't done that, then the ball would never have run into the wall. 771 00:37:08,910 --> 00:37:11,880 So it's time to talk a little bit more about these colliders 772 00:37:11,880 --> 00:37:15,330 and how they work better. 773 00:37:15,330 --> 00:37:22,460 But first let's adjust a little bit how this whole colliding 774 00:37:22,460 --> 00:37:25,070 thing is messing up in Unity. 775 00:37:25,070 --> 00:37:29,600 So the easy fix for why the ball is running through these mountains 776 00:37:29,600 --> 00:37:32,270 and through the castle is that the ball is just too small. 777 00:37:32,270 --> 00:37:35,524 And when Unity is given more points to work with, and you have a bigger ball, 778 00:37:35,524 --> 00:37:37,940 things will look better because when you crash into stuff, 779 00:37:37,940 --> 00:37:39,780 your camera won't be right up against the wall. 780 00:37:39,780 --> 00:37:41,780 It will have a little bit of space in between it 781 00:37:41,780 --> 00:37:43,739 so you feel like you're actually, like, bumping 782 00:37:43,739 --> 00:37:45,154 into things that are farther away. 783 00:37:45,154 --> 00:37:47,760 And you can see what's going on when you bump into things. 784 00:37:47,760 --> 00:37:50,900 And the other reason is that it gives Unity more points 785 00:37:50,900 --> 00:37:53,240 to deal with so when it's trying to compute collisions, 786 00:37:53,240 --> 00:37:54,650 it actually has a better chance of saying, 787 00:37:54,650 --> 00:37:56,790 oh, there's actually a collision going on here. 788 00:37:56,790 --> 00:38:00,680 So I'm actually going to make our ball 50 times bigger. 789 00:38:00,680 --> 00:38:04,730 And just to give an idea of what this sort of looks like-- 790 00:38:04,730 --> 00:38:11,990 as we're playing our game, I'm going to drag the scene down here and orient it 791 00:38:11,990 --> 00:38:13,610 so we can kind of see what's going on. 792 00:38:13,610 --> 00:38:20,320 793 00:38:20,320 --> 00:38:21,140 There we go. 794 00:38:21,140 --> 00:38:29,520 And then, as we play the game, we can see our ball rolling around down here. 795 00:38:29,520 --> 00:38:30,884 And then as we move-- 796 00:38:30,884 --> 00:38:33,050 so this is what's actually going on in the game-- is 797 00:38:33,050 --> 00:38:37,010 that we've got this ball with a camera inside of it rolling around 798 00:38:37,010 --> 00:38:39,390 and now it will actually bump into stuff. 799 00:38:39,390 --> 00:38:42,950 And if we notice, as we try to run into mountains and things, 800 00:38:42,950 --> 00:38:47,600 it stops on, like, flying through them weirdly. 801 00:38:47,600 --> 00:38:54,430 So now you can kind of have a sort of physical interaction with the objects. 802 00:38:54,430 --> 00:38:57,892 And that, for the most part, fixes most of the issues. 803 00:38:57,892 --> 00:38:59,850 Another potential issue that we're dealing with 804 00:38:59,850 --> 00:39:02,490 is that Unity really doesn't like what we did in the code 805 00:39:02,490 --> 00:39:06,720 there where we literally just set the velocity to be a particular value. 806 00:39:06,720 --> 00:39:10,740 Much like most of physics, it doesn't like instantaneously setting velocities 807 00:39:10,740 --> 00:39:13,260 and deals much better with setting forces. 808 00:39:13,260 --> 00:39:16,290 And so if we switch over our code to using forces, 809 00:39:16,290 --> 00:39:18,220 it will work a heck of a lot better. 810 00:39:18,220 --> 00:39:19,840 So let's do that. 811 00:39:19,840 --> 00:39:27,150 I'm going to click on Fly and it's now time to become a programming Jedi 812 00:39:27,150 --> 00:39:29,160 and learn how to use the force. 813 00:39:29,160 --> 00:39:35,802 So we're going to make a new public acceleration 814 00:39:35,802 --> 00:39:37,010 and it's going to be a float. 815 00:39:37,010 --> 00:39:42,950 816 00:39:42,950 --> 00:39:46,980 And instead of having a speed, we're going to call this max speed now. 817 00:39:46,980 --> 00:39:51,740 We will still limit the speed so that it doesn't accelerate infinitely fast. 818 00:39:51,740 --> 00:39:57,270 And then we're still going to want to follow particular pointer. 819 00:39:57,270 --> 00:40:02,450 So here again, we still want to get the rigid body. 820 00:40:02,450 --> 00:40:05,150 And then this time, though, we're going to add a force to it. 821 00:40:05,150 --> 00:40:08,630 822 00:40:08,630 --> 00:40:11,780 Not [INAUDIBLE], just add force. 823 00:40:11,780 --> 00:40:12,740 Thank you. 824 00:40:12,740 --> 00:40:17,330 All right, then this force has to be a three dimensional vector, which is just 825 00:40:17,330 --> 00:40:22,290 going to be our acceleration times the direction that the head is pointing in. 826 00:40:22,290 --> 00:40:26,770 827 00:40:26,770 --> 00:40:31,780 And then we've got this one weird last term, which is time.deltatime. 828 00:40:31,780 --> 00:40:37,390 So I'm honestly not exactly sure how time.deltatime works. 829 00:40:37,390 --> 00:40:40,110 It's more of an intuition for me, from what I've seen online, 830 00:40:40,110 --> 00:40:43,300 where any single time you have an action that you want to take place, 831 00:40:43,300 --> 00:40:47,670 like adding a force, and it takes place in between frames 832 00:40:47,670 --> 00:40:50,280 and you want it to add just the right amount of force 833 00:40:50,280 --> 00:40:52,710 for that particular frame, you want to multiply 834 00:40:52,710 --> 00:40:55,350 whatever vector you are doing by time.deltatime 835 00:40:55,350 --> 00:40:59,040 and it will allow you to actually get the object 836 00:40:59,040 --> 00:41:01,570 to move forward at the correct speed. 837 00:41:01,570 --> 00:41:04,426 So if you're just-- if you're confused kind of like I am, 838 00:41:04,426 --> 00:41:05,550 you can do searches online. 839 00:41:05,550 --> 00:41:09,270 And what I generally ask is, like, does ad force use time.deltatime 840 00:41:09,270 --> 00:41:13,720 and you'll usually find some answers online regarding how that works. 841 00:41:13,720 --> 00:41:14,952 So we can out ad a force. 842 00:41:14,952 --> 00:41:17,910 And then, again, we're going to want to actually limit it to max speed. 843 00:41:17,910 --> 00:41:23,560 So our rb.velocity is equal to max speed. 844 00:41:23,560 --> 00:41:26,470 And here we actually want to limit velocity. 845 00:41:26,470 --> 00:41:28,720 So we're going to do vector 3, which is just 846 00:41:28,720 --> 00:41:32,710 the three dimensional-- it's the class for three dimensional vectors. 847 00:41:32,710 --> 00:41:39,450 And we want to clamp the magnitude to be max speed. 848 00:41:39,450 --> 00:41:42,592 And the vector we want to clamp is its own velocity. 849 00:41:42,592 --> 00:41:45,250 850 00:41:45,250 --> 00:41:47,150 And max speed. 851 00:41:47,150 --> 00:41:51,670 852 00:41:51,670 --> 00:41:57,680 So this will take the velocity and set it to make sure that it's always 853 00:41:57,680 --> 00:41:59,720 at max speed or less than it. 854 00:41:59,720 --> 00:42:02,870 Again, like I said before, Unity still doesn't quite like this. 855 00:42:02,870 --> 00:42:05,210 And this isn't the perfect way of doing things. 856 00:42:05,210 --> 00:42:07,880 Ideally, what we would do, is if you were, like, moving forward 857 00:42:07,880 --> 00:42:10,520 at the max speed, it would then start to cut out 858 00:42:10,520 --> 00:42:13,800 whatever component of that particular direction you're moving in. 859 00:42:13,800 --> 00:42:15,810 So if you started to turn, it would still turn 860 00:42:15,810 --> 00:42:18,580 but it would kind of limit how much more forwards you can move. 861 00:42:18,580 --> 00:42:20,580 And always make sure that that speed's the same. 862 00:42:20,580 --> 00:42:23,000 I didn't want to do any of that complicated math here. 863 00:42:23,000 --> 00:42:25,560 This will still work great for what we want to do here. 864 00:42:25,560 --> 00:42:26,301 So we'll do that. 865 00:42:26,301 --> 00:42:29,300 If you want to program that on your own, it shouldn't be that difficult. 866 00:42:29,300 --> 00:42:32,091 But I thought it would be easier to do-- show a simple example here 867 00:42:32,091 --> 00:42:33,720 of how that works. 868 00:42:33,720 --> 00:42:40,310 So switching back to Unity, we should find here that this will update. 869 00:42:40,310 --> 00:42:43,410 Again, I like forcing it to kind of play through stuff 870 00:42:43,410 --> 00:42:44,850 and then update based on that. 871 00:42:44,850 --> 00:42:48,750 There we go-- acceleration-- 872 00:42:48,750 --> 00:42:52,730 so acceleration is how quickly it's going to adapt when we turn our heads. 873 00:42:52,730 --> 00:42:54,680 So if we set it to be something, like-- 874 00:42:54,680 --> 00:42:58,000 we can actually adjust these values as we go. 875 00:42:58,000 --> 00:43:01,260 Let's set our speed back to 50 like we had it before. 876 00:43:01,260 --> 00:43:04,840 And I'll adjust these values as we play. 877 00:43:04,840 --> 00:43:09,460 So we'll notice that if we set it to 10, it's just barely moving right now. 878 00:43:09,460 --> 00:43:12,880 So maybe we'll bump it up to be, like, 10 times higher. 879 00:43:12,880 --> 00:43:14,890 And now we can see that we kind of start moving, 880 00:43:14,890 --> 00:43:17,090 but still it's very hard to control. 881 00:43:17,090 --> 00:43:19,390 And so even at 1,000 really-- 882 00:43:19,390 --> 00:43:21,730 now we actually start getting moving. 883 00:43:21,730 --> 00:43:25,660 But if I'm, like, aiming towards this, and then I 884 00:43:25,660 --> 00:43:27,730 start to turn my head like I want to go that way, 885 00:43:27,730 --> 00:43:32,360 it takes a little bit for it actually move in the direction 886 00:43:32,360 --> 00:43:33,830 that I'm tilting my head. 887 00:43:33,830 --> 00:43:35,570 So if you like that sort of effect, where 888 00:43:35,570 --> 00:43:37,940 if I were to turn directly around, I'd still 889 00:43:37,940 --> 00:43:41,070 be moving backwards a little bit-- and then more like a slingshot or rubber 890 00:43:41,070 --> 00:43:44,260 band-- it kind of like, start moving forwards again. 891 00:43:44,260 --> 00:43:46,880 Then you can keep it around 1,000 or 2,000 or so. 892 00:43:46,880 --> 00:43:49,640 I don't like that effect, and so I just set it to be 10,000. 893 00:43:49,640 --> 00:43:52,490 And then whatever direction I move, I look in-- 894 00:43:52,490 --> 00:43:54,690 I pretty much move in that direction. 895 00:43:54,690 --> 00:43:56,330 So I happen to like it at that speed. 896 00:43:56,330 --> 00:43:59,930 And now we have something that's got better physics. 897 00:43:59,930 --> 00:44:03,500 So I keep on talking about this physics, but all we've really seen 898 00:44:03,500 --> 00:44:04,560 is bumping into things. 899 00:44:04,560 --> 00:44:08,180 So it's time for me to talk a little bit more about colliders and how they work. 900 00:44:08,180 --> 00:44:11,110 So you'll notice that here we've got a sphere collider. 901 00:44:11,110 --> 00:44:13,110 And this has a whole bunch of different options. 902 00:44:13,110 --> 00:44:15,740 One of these being a physic material. 903 00:44:15,740 --> 00:44:19,670 So what physic materials do is they determine how objects interact 904 00:44:19,670 --> 00:44:21,390 when they bump into each other. 905 00:44:21,390 --> 00:44:23,280 So let's create our first physics material 906 00:44:23,280 --> 00:44:26,460 just to show what particular options are available. 907 00:44:26,460 --> 00:44:31,540 I'm going to go back to my assets, create a new folder, 908 00:44:31,540 --> 00:44:37,946 material, and then another folder for physic materials. 909 00:44:37,946 --> 00:44:41,600 910 00:44:41,600 --> 00:44:46,080 And then inside of this folder we can create a new physic material. 911 00:44:46,080 --> 00:44:49,010 912 00:44:49,010 --> 00:44:53,270 So we have options here for dynamic friction, static friction, bounciness, 913 00:44:53,270 --> 00:44:55,370 and then how they combine them. 914 00:44:55,370 --> 00:44:57,560 So let's say one of my objects-- 915 00:44:57,560 --> 00:44:59,750 like, the mountains are super duper bouncy-- 916 00:44:59,750 --> 00:45:01,880 and my player is not bouncy at all. 917 00:45:01,880 --> 00:45:05,060 How are you going to figure out when they collide what's going to happen? 918 00:45:05,060 --> 00:45:06,150 So there are a couple of options. 919 00:45:06,150 --> 00:45:07,390 We can either average them. 920 00:45:07,390 --> 00:45:09,080 We can figure out the minimum of them. 921 00:45:09,080 --> 00:45:11,120 We can multiply them together since they're both 922 00:45:11,120 --> 00:45:13,590 going to be values between 0 and 1. 923 00:45:13,590 --> 00:45:15,250 Or we can find the maximum of them. 924 00:45:15,250 --> 00:45:19,180 Here, I'm going to make this super duper bouncy no matter what bounces into it. 925 00:45:19,180 --> 00:45:22,160 So we're going to set bounciness to the maximum value of 1. 926 00:45:22,160 --> 00:45:25,670 And no matter what your object is like, whenever you bounce into this, 927 00:45:25,670 --> 00:45:28,280 you're going to bounce off of the bounciness of one. 928 00:45:28,280 --> 00:45:33,990 And I'm going to call this, bouncy, because that's what it does. 929 00:45:33,990 --> 00:45:36,530 So now we have this bouncy physic material. 930 00:45:36,530 --> 00:45:40,280 And I happen to find it funny that mountains are generally 931 00:45:40,280 --> 00:45:41,150 not bouncy at all. 932 00:45:41,150 --> 00:45:44,090 But this is virtual reality, so our mountains can be bouncy. 933 00:45:44,090 --> 00:45:48,080 So you'll notice that your mountains already come with a terrain collider 934 00:45:48,080 --> 00:45:48,770 here. 935 00:45:48,770 --> 00:45:53,210 And this is what controls what happens when things bump into the mountains. 936 00:45:53,210 --> 00:45:58,930 And so we can move our bouncy over here to the material. 937 00:45:58,930 --> 00:46:01,810 And now our mountains will become bouncy and we can actually 938 00:46:01,810 --> 00:46:04,955 run through and see what happens when we run into mountains. 939 00:46:04,955 --> 00:46:08,680 940 00:46:08,680 --> 00:46:12,670 Oh, another thing to mention-- so you'll see here we're moving slow again. 941 00:46:12,670 --> 00:46:16,540 If you change these values while you're playing the game, 942 00:46:16,540 --> 00:46:19,380 they reset to the values that they originally were when you started. 943 00:46:19,380 --> 00:46:21,880 So you'll notice that when I first started that other thing, 944 00:46:21,880 --> 00:46:25,930 we started at 10, when I actually wanted it to be 10,000. 945 00:46:25,930 --> 00:46:30,790 So I actually have to quit out of the playing, edit it to 10,000, 946 00:46:30,790 --> 00:46:31,960 and then come back in. 947 00:46:31,960 --> 00:46:35,200 And now it will always default to 10,000 when we come back in. 948 00:46:35,200 --> 00:46:37,450 So there we are moving around. 949 00:46:37,450 --> 00:46:40,990 And it's time to see what happens if we run into one of these mountains. 950 00:46:40,990 --> 00:46:43,391 Will we bounce off? 951 00:46:43,391 --> 00:46:43,890 Boing! 952 00:46:43,890 --> 00:46:44,460 Boing! 953 00:46:44,460 --> 00:46:46,830 So you can see how now we bounce in between mountains. 954 00:46:46,830 --> 00:46:48,810 And if you get inside one of these pockets, 955 00:46:48,810 --> 00:46:52,030 you can kind of, like, bounce back and forth and all around. 956 00:46:52,030 --> 00:46:57,029 But if we try to run into the walls of the castle here, 957 00:46:57,029 --> 00:46:58,570 you'll notice we don't bounce at all. 958 00:46:58,570 --> 00:47:03,940 And that's because the physic collider on the castle doesn't have any bounce. 959 00:47:03,940 --> 00:47:07,420 You'll also notice, and I said earlier, that you'd 960 00:47:07,420 --> 00:47:11,620 see a better example of, like, displaying things from one side better. 961 00:47:11,620 --> 00:47:15,430 So I talked about how this sphere can only be displayed from one side 962 00:47:15,430 --> 00:47:16,480 overall. 963 00:47:16,480 --> 00:47:19,777 Here you'll notice that we can only see one side of the castle wall. 964 00:47:19,777 --> 00:47:22,360 So if we're looking at it from the outside, we see the castle. 965 00:47:22,360 --> 00:47:25,484 And if we're looking at it from the inside, we don't see the castle at all. 966 00:47:25,484 --> 00:47:29,495 That's mostly because the person who did this didn't use good practices when 967 00:47:29,495 --> 00:47:30,370 creating their model. 968 00:47:30,370 --> 00:47:34,900 So the fbx for this one only used these things called planes on the outside 969 00:47:34,900 --> 00:47:35,890 instead of using cubes. 970 00:47:35,890 --> 00:47:38,377 So it only displays planes from those one side. 971 00:47:38,377 --> 00:47:41,210 Cubes on the other hand, if you're looking at them from the outside, 972 00:47:41,210 --> 00:47:43,880 it'll be visible from all sides of the outside. 973 00:47:43,880 --> 00:47:47,410 So that's mainly an issue with this fbx object. 974 00:47:47,410 --> 00:47:49,720 And I thought about maybe choosing a different one. 975 00:47:49,720 --> 00:47:51,820 But I also thought, hey, this is a great example 976 00:47:51,820 --> 00:47:56,830 of how to deal with issues that you might encounter when creating VR. 977 00:47:56,830 --> 00:48:00,790 So another potential issue is because they only display from one side, 978 00:48:00,790 --> 00:48:03,640 it also means their collider only happens on one side, too. 979 00:48:03,640 --> 00:48:05,770 So you may be wondering how it is that I'm actually 980 00:48:05,770 --> 00:48:08,436 running into something here when there's nothing in front of me. 981 00:48:08,436 --> 00:48:12,317 Well, it turns out the value that I chose for a ball of radius of 50 982 00:48:12,317 --> 00:48:15,400 makes it so that it's actually running into those things at the top there. 983 00:48:15,400 --> 00:48:17,230 It's not running into any wall here. 984 00:48:17,230 --> 00:48:22,940 And if I adjust our player to be, like, a size of 30 or so-- 985 00:48:22,940 --> 00:48:26,850 you'll notice that, one, we start moving faster because the ball's smaller. 986 00:48:26,850 --> 00:48:31,170 But also, if we try to run through the wall on this side, 987 00:48:31,170 --> 00:48:32,810 we can actually fit through it. 988 00:48:32,810 --> 00:48:35,430 So it is actually running through those things on the top. 989 00:48:35,430 --> 00:48:36,522 And if we run through-- 990 00:48:36,522 --> 00:48:39,230 try to run through it on this side, it does run through the wall. 991 00:48:39,230 --> 00:48:43,380 So you can do different things like that. 992 00:48:43,380 --> 00:48:49,290 So changing the sphere to 50 was a way to make it so, to the user, 993 00:48:49,290 --> 00:48:52,400 it feels like that's still a wall, even though the wall isn't there 994 00:48:52,400 --> 00:48:55,670 just because the person did manage to put some things up on the top 995 00:48:55,670 --> 00:48:57,876 where the ball could be big enough to run into. 996 00:48:57,876 --> 00:48:59,750 So it's little tips and tricks like that that 997 00:48:59,750 --> 00:49:03,000 will make your world feel a lot better to your user, 998 00:49:03,000 --> 00:49:06,145 even though things might not actually be working within your program. 999 00:49:06,145 --> 00:49:09,060 1000 00:49:09,060 --> 00:49:11,640 So another thing that colliders can do that I didn't mention 1001 00:49:11,640 --> 00:49:13,820 is that they can act as triggers. 1002 00:49:13,820 --> 00:49:17,181 So in one of the apps that I made, I wanted the ball to-- 1003 00:49:17,181 --> 00:49:19,680 I wanted to have certain checkpoints as you went through it. 1004 00:49:19,680 --> 00:49:26,310 And so colliders can focus on how objects interact with each other 1005 00:49:26,310 --> 00:49:27,810 and how they bounce off and whatnot. 1006 00:49:27,810 --> 00:49:30,840 But they can also act as, like, sensors and be completely, 1007 00:49:30,840 --> 00:49:32,309 non-physically interactive. 1008 00:49:32,309 --> 00:49:33,600 You can run right through them. 1009 00:49:33,600 --> 00:49:37,060 But as soon as you touch them, they'll trigger in your code. 1010 00:49:37,060 --> 00:49:40,309 And so you can look up more on how to use colliders as triggers 1011 00:49:40,309 --> 00:49:41,850 and then you can use them as sensors. 1012 00:49:41,850 --> 00:49:44,100 So, like, when my object ran into a checkpoint, 1013 00:49:44,100 --> 00:49:47,430 the checkpoint was literally just a cube, an invisible cube that 1014 00:49:47,430 --> 00:49:50,220 had a collider that was a trigger on it, and when 1015 00:49:50,220 --> 00:49:52,080 the ball touched that particular trigger, 1016 00:49:52,080 --> 00:49:54,996 it set off something that made it so that that was the new checkpoint. 1017 00:49:54,996 --> 00:49:57,180 So that trigger button does that and makes 1018 00:49:57,180 --> 00:50:00,180 it so that things won't bounce off of it or physically interact with it. 1019 00:50:00,180 --> 00:50:02,702 But you can then access the trigger within your code. 1020 00:50:02,702 --> 00:50:05,600 1021 00:50:05,600 --> 00:50:08,280 So now that we've actually done through this-- 1022 00:50:08,280 --> 00:50:09,680 gone through all of this-- 1023 00:50:09,680 --> 00:50:11,960 our world is actually complete. 1024 00:50:11,960 --> 00:50:16,054 This is the final version that we'll be using for this talk. 1025 00:50:16,054 --> 00:50:17,720 And so you can bounce off the mountains. 1026 00:50:17,720 --> 00:50:19,636 And feel free to adjust this however you want. 1027 00:50:19,636 --> 00:50:22,670 Use different terrains, figure out other cool new stuff 1028 00:50:22,670 --> 00:50:28,550 to add, use better fbx materials, and add in cooler castles or other objects 1029 00:50:28,550 --> 00:50:31,130 that you find interesting, and color things super duper cool, 1030 00:50:31,130 --> 00:50:32,907 and make better mountains. 1031 00:50:32,907 --> 00:50:35,240 So you can do a heck of a lot of stuff with all of this. 1032 00:50:35,240 --> 00:50:38,540 And I think hopefully you'll enjoy it and putting it on your phone. 1033 00:50:38,540 --> 00:50:40,940 So that's exactly what we're going to try to do next, 1034 00:50:40,940 --> 00:50:43,430 is put this onto your phone. 1035 00:50:43,430 --> 00:50:47,750 So in Unity, there is an option called Build Settings. 1036 00:50:47,750 --> 00:50:50,990 And this is how we go through and put things onto your phone. 1037 00:50:50,990 --> 00:50:56,510 If you have Android, you're going to want to use the Android platform here. 1038 00:50:56,510 --> 00:50:59,600 When you download Unity, there should have been something like, 1039 00:50:59,600 --> 00:51:00,860 do you want to install iOS? 1040 00:51:00,860 --> 00:51:02,151 Do you want to install Android? 1041 00:51:02,151 --> 00:51:05,280 If you clicked on that bit.ly link to VR Seminar 1042 00:51:05,280 --> 00:51:09,500 and mentioned that you have to select which version of a phone you have. 1043 00:51:09,500 --> 00:51:13,070 So I did download the iOS one when I downloaded Unity. 1044 00:51:13,070 --> 00:51:16,490 And so I can select Unity here and say switch platform. 1045 00:51:16,490 --> 00:51:19,740 This takes a while and so I'm not going to actually do that right now. 1046 00:51:19,740 --> 00:51:23,360 I'm going to go through and open up with a different project that has already 1047 00:51:23,360 --> 00:51:26,240 been switched to iOS. 1048 00:51:26,240 --> 00:51:28,580 So I'm going to-- 1049 00:51:28,580 --> 00:51:32,300 oh, a mention on saving, which I should have been doing a lot through this-- 1050 00:51:32,300 --> 00:51:36,320 but I've read online that saving your scene also saves your projects. 1051 00:51:36,320 --> 00:51:39,650 I had a time when I was working on this and I saved my scenes 1052 00:51:39,650 --> 00:51:43,636 and then accidentally did a folder move and some of the objects or things 1053 00:51:43,636 --> 00:51:45,010 that I had created weren't there. 1054 00:51:45,010 --> 00:51:47,660 So I always saved the scene and saved the project. 1055 00:51:47,660 --> 00:51:50,010 Saving the project does not save your scene at all, 1056 00:51:50,010 --> 00:51:52,460 because there are some things that you may want to change your project that 1057 00:51:52,460 --> 00:51:53,418 don't affect the scene. 1058 00:51:53,418 --> 00:51:55,570 And so saving your scene should save your project, 1059 00:51:55,570 --> 00:51:56,820 but I've had issues with that. 1060 00:51:56,820 --> 00:51:59,500 So I always do save scene and save project. 1061 00:51:59,500 --> 00:52:02,390 Where I always just save my scenes as Main, 1062 00:52:02,390 --> 00:52:06,250 and then they show up here as a scene, and then 1063 00:52:06,250 --> 00:52:09,020 sticking with what I've done before-- 1064 00:52:09,020 --> 00:52:13,130 calling this scenes-- and then putting Main as a scene in there. 1065 00:52:13,130 --> 00:52:15,740 So that also means that if you make a new Unity Project, 1066 00:52:15,740 --> 00:52:19,340 and you want to use the same scene in that project, 1067 00:52:19,340 --> 00:52:23,090 you can just drag the scene inside of your folder file system 1068 00:52:23,090 --> 00:52:25,430 for your computer, drag the scene into the new assets 1069 00:52:25,430 --> 00:52:30,320 folder for that new project, and boom, the scene will be in there. 1070 00:52:30,320 --> 00:52:33,710 All right, so let's open up that project now and save this one. 1071 00:52:33,710 --> 00:52:40,632 So Save Project and Save Scenes and we can open up this new one. 1072 00:52:40,632 --> 00:52:41,598 Open project. 1073 00:52:41,598 --> 00:52:46,920 1074 00:52:46,920 --> 00:52:51,240 All right, so I'll open up this. 1075 00:52:51,240 --> 00:52:54,100 And inside, see it-- it says 50 Seminar. 1076 00:52:54,100 --> 00:53:03,040 1077 00:53:03,040 --> 00:53:06,860 All right, which one do I want? 1078 00:53:06,860 --> 00:53:07,870 I want the CS50. 1079 00:53:07,870 --> 00:53:11,575 1080 00:53:11,575 --> 00:53:14,140 Ah, it's under Practice [INAUDIBLE]. 1081 00:53:14,140 --> 00:53:16,750 So this is the second test. 1082 00:53:16,750 --> 00:53:19,510 And this is the world that I had built before this. 1083 00:53:19,510 --> 00:53:22,325 You'll see that Unity is restarting and building up this new world. 1084 00:53:22,325 --> 00:53:24,700 And this is one that I've already uploaded onto my phone. 1085 00:53:24,700 --> 00:53:32,480 1086 00:53:32,480 --> 00:53:34,790 So you'll see it looks very similar to the one 1087 00:53:34,790 --> 00:53:37,200 that we just built except for this one. 1088 00:53:37,200 --> 00:53:39,200 You'll notice that everything is dark right now. 1089 00:53:39,200 --> 00:53:41,780 Unity takes a little bit to calculate the light 1090 00:53:41,780 --> 00:53:43,780 and how the light should reflect off of objects. 1091 00:53:43,780 --> 00:53:47,480 So that's what just happened there-- is it finally figured out how to calculate 1092 00:53:47,480 --> 00:53:49,370 how the light bounces off of objects. 1093 00:53:49,370 --> 00:53:51,350 And that's one of the other big things that you 1094 00:53:51,350 --> 00:53:53,350 might run into if you make your terrain too big, 1095 00:53:53,350 --> 00:53:55,350 is that it just can't calculate the light. 1096 00:53:55,350 --> 00:53:57,440 So if we go into to Build Settings-- 1097 00:53:57,440 --> 00:53:59,240 here you'll see that it's already on iOS. 1098 00:53:59,240 --> 00:54:01,590 So now we can look at player settings. 1099 00:54:01,590 --> 00:54:05,180 Here, if you're an iOS developer, you're going to want to put your company name. 1100 00:54:05,180 --> 00:54:08,669 I'm not-- I just have, like, the free version of iOS developing, 1101 00:54:08,669 --> 00:54:11,210 so you can really choose whatever you want to be your company 1102 00:54:11,210 --> 00:54:12,860 name-- your project name. 1103 00:54:12,860 --> 00:54:15,770 And then you're also going to want to go to Other Settings 1104 00:54:15,770 --> 00:54:19,880 and copy whatever you have there in to here. 1105 00:54:19,880 --> 00:54:22,700 It really doesn't matter whether or not they match all that much. 1106 00:54:22,700 --> 00:54:24,770 You can choose pretty much whatever you want. 1107 00:54:24,770 --> 00:54:27,680 And I think it works better if you copy one to the other, 1108 00:54:27,680 --> 00:54:31,890 and it might be necessary, but really, any value should work. 1109 00:54:31,890 --> 00:54:38,360 On these, you can change your version and whatnot if you want that. 1110 00:54:38,360 --> 00:54:41,450 This virtual reality supported button-- 1111 00:54:41,450 --> 00:54:42,930 do not check it. 1112 00:54:42,930 --> 00:54:45,281 This is for the new versions of virtual reality. 1113 00:54:45,281 --> 00:54:47,030 And you'll see that you can add Cardboard. 1114 00:54:47,030 --> 00:54:48,260 You don't want to do that. 1115 00:54:48,260 --> 00:54:49,370 Leave it unchecked. 1116 00:54:49,370 --> 00:54:51,890 For this version of virtual reality, all of these settings 1117 00:54:51,890 --> 00:54:56,910 are inside Cardboard Main and it will make it a virtual reality for you. 1118 00:54:56,910 --> 00:54:59,620 So leave that button unchecked for sure. 1119 00:54:59,620 --> 00:55:01,710 In your resolution and presentation, you're 1120 00:55:01,710 --> 00:55:05,040 going to want to make sure it's listed as Landscape Left. 1121 00:55:05,040 --> 00:55:07,050 And then all of the defaults for everything else 1122 00:55:07,050 --> 00:55:09,544 should work pretty much as expected. 1123 00:55:09,544 --> 00:55:13,280 1124 00:55:13,280 --> 00:55:17,970 Another thing to mention is there are particular icons that you 1125 00:55:17,970 --> 00:55:20,290 can add here and override them. 1126 00:55:20,290 --> 00:55:24,870 Or if you just want to use the general icon, you can put in any PNG file right 1127 00:55:24,870 --> 00:55:26,550 here as the icon for your app. 1128 00:55:26,550 --> 00:55:28,230 I'm not going to make one here. 1129 00:55:28,230 --> 00:55:29,160 It's totally fine. 1130 00:55:29,160 --> 00:55:32,400 It will make like a little symbol for you that looks like the Unity symbol. 1131 00:55:32,400 --> 00:55:34,830 It's kind of cool. 1132 00:55:34,830 --> 00:55:36,810 Anything else I need to do here? 1133 00:55:36,810 --> 00:55:39,690 Nope, so this is all you need to do in Unity 1134 00:55:39,690 --> 00:55:41,440 and then you can click the Build button. 1135 00:55:41,440 --> 00:55:44,340 Again, this takes a fairly long time, and so I'm 1136 00:55:44,340 --> 00:55:47,640 going to pull up the one that I've already built for this. 1137 00:55:47,640 --> 00:55:49,320 Now it's time to start using Xcode. 1138 00:55:49,320 --> 00:55:53,280 So Unity, when you build stuff, it will build it for that particular platform. 1139 00:55:53,280 --> 00:55:55,740 So you'll notice that we chose iOS as the platform. 1140 00:55:55,740 --> 00:55:59,550 So iOS is openable in Xcode. 1141 00:55:59,550 --> 00:56:04,080 So you're going to go and open and find it. 1142 00:56:04,080 --> 00:56:08,280 So you'll notice that I had it in the CS50 Seminar. 1143 00:56:08,280 --> 00:56:12,150 When you choose to build your project, it will open up and say, like, here's 1144 00:56:12,150 --> 00:56:12,720 a new folder. 1145 00:56:12,720 --> 00:56:13,440 Where do you want to put it? 1146 00:56:13,440 --> 00:56:16,230 Just name that folder and then save it wherever it tells you to. 1147 00:56:16,230 --> 00:56:18,510 Or if you want to put it in a different spot, you can. 1148 00:56:18,510 --> 00:56:22,410 I like putting mine underneath the objects underneath the folder. 1149 00:56:22,410 --> 00:56:25,590 So see here-- practice for CS50 Seminar-- 1150 00:56:25,590 --> 00:56:29,700 if I go into the folder for that, I have all of these different versions 1151 00:56:29,700 --> 00:56:31,080 that I've actually built. 1152 00:56:31,080 --> 00:56:34,110 Second test 3 is the latest version that I've built 1153 00:56:34,110 --> 00:56:36,540 and so I'm going to open the folder. 1154 00:56:36,540 --> 00:56:40,230 If you look inside of this folder, there is an Xcode project inside of it. 1155 00:56:40,230 --> 00:56:42,330 You don't want to open that project. 1156 00:56:42,330 --> 00:56:44,462 If you do this on the newer versions of the SDK, 1157 00:56:44,462 --> 00:56:46,170 it will give you some really weird errors 1158 00:56:46,170 --> 00:56:48,790 that are super hard to figure out what's going on. 1159 00:56:48,790 --> 00:56:52,830 The trick is to open up the folder and not the project inside of it. 1160 00:56:52,830 --> 00:56:57,150 And so open up this second test three folder-- or for you it will be, like, 1161 00:56:57,150 --> 00:56:59,970 CS50 Project. 1162 00:56:59,970 --> 00:57:02,530 And inside of that, there should be another one 1163 00:57:02,530 --> 00:57:07,220 that's the name that you put in when you built the project. 1164 00:57:07,220 --> 00:57:10,930 So here, for you guys, it will probably show up just with the Unity iPhone 1165 00:57:10,930 --> 00:57:11,590 here. 1166 00:57:11,590 --> 00:57:14,772 You can click on it and it should pop up with this General tab. 1167 00:57:14,772 --> 00:57:17,230 It will show a little error here because you'll have nobody 1168 00:57:17,230 --> 00:57:19,360 selected for your development team. 1169 00:57:19,360 --> 00:57:21,250 And then you can just choose yourself. 1170 00:57:21,250 --> 00:57:25,540 And it will manage with all these profiles. 1171 00:57:25,540 --> 00:57:27,970 Another thing you have to fix in here is that they 1172 00:57:27,970 --> 00:57:30,090 didn't add in the security framework. 1173 00:57:30,090 --> 00:57:33,520 And so you have to scroll down to Linked Frameworks and Libraries, 1174 00:57:33,520 --> 00:57:36,500 add in the security framework. 1175 00:57:36,500 --> 00:57:37,520 And then fix that. 1176 00:57:37,520 --> 00:57:41,370 You'll see that I had already added it in, so it's just added in again. 1177 00:57:41,370 --> 00:57:44,360 And again, another odd thing is in Build Settings, 1178 00:57:44,360 --> 00:57:48,720 you should scroll down until you find something called Enable Bit Code. 1179 00:57:48,720 --> 00:57:53,030 You want to make sure that that bit code is disabled. 1180 00:57:53,030 --> 00:57:55,640 Unfortunately, this makes it so that any virtual reality 1181 00:57:55,640 --> 00:57:59,570 app you make can't be uploaded online to the App Store. 1182 00:57:59,570 --> 00:58:02,720 I'm not exactly sure of any workarounds for this currently. 1183 00:58:02,720 --> 00:58:04,610 And so if you find any through your searches, 1184 00:58:04,610 --> 00:58:07,610 please let me know and let other people who are developers know. 1185 00:58:07,610 --> 00:58:09,890 Because I've done a lot of research on this 1186 00:58:09,890 --> 00:58:13,670 and haven't figured out any way to get around the errors that-- 1187 00:58:13,670 --> 00:58:16,850 having bit code enabled creates errors, and the only way to get around them 1188 00:58:16,850 --> 00:58:18,359 so far has been to disable bit code. 1189 00:58:18,359 --> 00:58:20,900 But when you do that, you can't upload apps to the App Store. 1190 00:58:20,900 --> 00:58:23,170 So if you find a way around that, that would be great. 1191 00:58:23,170 --> 00:58:25,050 Please let me know. 1192 00:58:25,050 --> 00:58:27,900 But for now, we're just going to disable that. 1193 00:58:27,900 --> 00:58:31,319 And then everything should be up and ready to go. 1194 00:58:31,319 --> 00:58:33,110 And so you plug-in your phone and make sure 1195 00:58:33,110 --> 00:58:35,750 it's unlocked so it can actually run on it. 1196 00:58:35,750 --> 00:58:38,240 And then hit Run and it will upload to your phone. 1197 00:58:38,240 --> 00:58:40,550 So this will actually take a lot longer for you 1198 00:58:40,550 --> 00:58:46,460 guys because it will have to run through and actually create the entire project 1199 00:58:46,460 --> 00:58:48,320 and compile it and run on your phone. 1200 00:58:48,320 --> 00:58:51,116 But then once you're done, you can see that it started 1201 00:58:51,116 --> 00:58:52,490 running on my phone a little bit. 1202 00:58:52,490 --> 00:58:55,550 I'm not exactly sure how easily the cameras picked this up. 1203 00:58:55,550 --> 00:58:56,990 But you have your phone here. 1204 00:58:56,990 --> 00:59:01,270 You can unpack whatever Google Cardboard you've gotten. 1205 00:59:01,270 --> 00:59:03,850 This one happens to come in a box like this. 1206 00:59:03,850 --> 00:59:05,170 It has a silly face on front. 1207 00:59:05,170 --> 00:59:08,410 I actually used this for my Harvard interview and it was great. 1208 00:59:08,410 --> 00:59:13,030 And it made me a lot more comfortable to see my supposedly scary Harvard 1209 00:59:13,030 --> 00:59:16,280 interviewer put this on and look like this and is looking around. 1210 00:59:16,280 --> 00:59:19,660 So thank you, interviewer, for helping me feel a little bit more 1211 00:59:19,660 --> 00:59:21,130 comfortable during the interview. 1212 00:59:21,130 --> 00:59:26,380 So you put this on and you put your phone inside of it like this. 1213 00:59:26,380 --> 00:59:30,500 And then if you look around, you should be 1214 00:59:30,500 --> 00:59:33,300 able to see around inside of your world. 1215 00:59:33,300 --> 00:59:36,320 And that will be your virtual reality application. 1216 00:59:36,320 --> 00:59:38,750 Do make sure that when you're exporting-- 1217 00:59:38,750 --> 00:59:44,090 I know that for displaying, we mentioned that this-- 1218 00:59:44,090 --> 00:59:45,260 where was it-- 1219 00:59:45,260 --> 00:59:48,800 VR Mode Enabled should be unchecked so that you can see things easily 1220 00:59:48,800 --> 00:59:51,020 inside this display. 1221 00:59:51,020 --> 00:59:54,230 You do want to have that checked when you export it, or else, what you'll get 1222 00:59:54,230 --> 00:59:57,188 is a version that doesn't use Google Cardboard where you should just be 1223 00:59:57,188 --> 00:59:59,150 looking like this around in your world. 1224 00:59:59,150 --> 01:00:02,080 1225 01:00:02,080 --> 01:00:07,790 So that brings us to the end of my presentation. 1226 01:00:07,790 --> 01:00:10,840 There are a couple extra things that you can fool around with. 1227 01:00:10,840 --> 01:00:12,420 Google gives you the option-- 1228 01:00:12,420 --> 01:00:15,150 there's like an alignment marker, a settings button, 1229 01:00:15,150 --> 01:00:19,300 a Back button that show up on the app here that you can toggle around with. 1230 01:00:19,300 --> 01:00:21,610 I hope you guys explore more with Unity and are 1231 01:00:21,610 --> 01:00:24,820 able to find out how to add in things like trees and wind 1232 01:00:24,820 --> 01:00:28,390 and fool around with all the cool options that Unity has to offer. 1233 01:00:28,390 --> 01:00:31,270 You can also fool around with, like, sounds and getting things, 1234 01:00:31,270 --> 01:00:33,990 like, the running water on those fountains 1235 01:00:33,990 --> 01:00:36,490 there-- and getting it to make it so that as you get closer, 1236 01:00:36,490 --> 01:00:38,800 it sounds more and more like the fountain's actually running and just 1237 01:00:38,800 --> 01:00:41,710 doing a whole bunch of cool worlds and making them, and encouraging 1238 01:00:41,710 --> 01:00:43,168 your friends to make them, as well. 1239 01:00:43,168 --> 01:00:44,240 So thank you so much. 1240 01:00:44,240 --> 01:00:46,780 And this is the CS50 Seminar. 1241 01:00:46,780 --> 01:00:48,806