From the course: Unity 3D 2019 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Writing the code

Writing the code - Unity Tutorial

From the course: Unity 3D 2019 Essential Training

Start my 1-month free trial

Writing the code

- [Instructor] So let's go ahead and implement a script that will play or sound source only when we approach it. So we'll implement the script for the coffee machine but feel free to implement it too for the fireplace. So, the first thing we're going to do is create a folder, which is called a Script, so right click, Create, and then Folder, and we're going to name it Script, and then inside of that folder, we'll create a new Script. So, right click, Create, C sharp Script, and we're going to call this Audio clip. So what we're going to do now is double click on that script so we can open up the editor that we need in this case. Okay, so when we first create a script inside of Unity, Unity adds a whole lot of stuff already for us so like I mentioned, previously, we're using a couple of libraries that Unity is importing automatically for us. Then, we're using the public class Audioclip, which is the name of the…

Contents