Make Games from Scratch (No Coding!) Part 2 - Getting Started with Playmaker in Unity | Brandon Wu | Skillshare

Make Games from Scratch (No Coding!) Part 2 - Getting Started with Playmaker in Unity

Brandon Wu, Founder of Studio Pepwuper - a Game Studio

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
13 Lessons (1h 34m)
    • 1. Introduction

      1:36
    • 2. Overview

      2:56
    • 3. Import Custom Package

      5:21
    • 4. Open Up PlayMaker UI

      3:56
    • 5. What is a FSM (Finite State Machine)

      4:54
    • 6. PlayMaker Example – Start State, Action Browser, Rotate, Translate, Wait, Finish

      18:15
    • 7. Frame, Update, Run-time

      7:54
    • 8. Action Browser, Mouse Down Event

      13:13
    • 9. PlayMaker UI Part 2

      7:38
    • 10. Disable, Enable, Editing during Play Mode

      5:32
    • 11. Empty Game Object, Add Audio

      13:56
    • 12. Lights On and Off – Toggle, Key Down

      7:10
    • 13. Play Mode Tint

      2:00

About This Class

h0BgNzM.jpg

Now that we have a basic understanding of Unity from the previous class, let's start creating some interactions in the scene. What is a game without player input anyway? 

We will be utilizing PlayMaker, a great add-on to Unity that allows designers and artists to create interactions quickly without coding. PlayMaker has been used in some of the bigges games like HEARTHSTONE: HEROES OF WARCRAFT!

The folks behind PlayMaker has kindly offers the students form the class a student version of the plugin that can be used for learning.

In this class, we will:

Create a scene with basic movements and interactions using PlayMaker:

Here are a few elements you can add to your scene. You don’t have to add them all but try to do as many of these as possible will help you get familiar with PlayMaker:

  • Click on an object to rotate
  • Press a key to toggle a color change for an object
  • Make a sound when clicking on an object
  • Move, rotate, and scale different objects in the scene
  • Rotate camera once when the game starts, or rotate camera continuously during the game
  • Press a key to toggle lighting on and off

Transcripts

1. Introduction: welcome to part to make games from scratch. And this is again a course about using unity and playmakers to make games and interactive experiences without the need to code. And I think it is a great way to get started with game development if you haven't taken first part link in the description or in the course of the section, so you can go and find the first part of this course on where we talked about basics and over the off unity what it is, what it looks like, what everything is. And in the second part, we are going to a cat playmaker playmaker as an add on to unity. It allows you to create interactions using this thing called us Finite state Machine will go over that in a minute. But essentially what allows you to do is creating interactions so cooked into all the incredible things that unity allows you to Teoh without having to write scripts. So this is This is a really good tour, and it's been used in actual games that's been released there as well. So we're gonna look at playmaker Brokenness. Look at some basic concepts off state machines and then after this, in part three and four, we will start making too small games and interactive experiences that you can use to practise the skills you've learned in part one and two. So tough for me to enjoy this. 2. Overview: Okay, we to now I am. I'm not in my office. Yes, you can see that. I mean this man cave at home. But I want to thank a lot of you for helping each other out on the floor. I think it's great that we're all making this a better experience for each other. And this week we are going to talk about Playmaker. And it's a tool that integrates with unity to allow us to creating directions and movements and different things inside the game without having to right programming like without having to use programming languages without having to code. And I think it's gonna be pretty fun. So hopefully you enjoy it. A couple things. First, I will try to answer as many questions on the forum as possible in this quickly as possible . And if I see a need for a new video, also record a new video and posted on the four home and also the description for the week. So if you haven't check up before, go there and it should just be on your left. Insiders discussions leg when you go to the syllabus. And so that's the first thing, and secondly, I think I got no, always be back on the class, and I realized there's a huge sort of very degree of understanding of the game words and different so the skill levels. So I will try to make the class as accessible as possible. And if you need help on anything, just email me. And I know it's tracking, make things easier and try to explain things in different ways and also if he are more advanced and you want help with other types of things, For example, we don't you probably won't be going into character animations and carried the controls. But if you want some help with that, post questions on the floor on and I'll try to get to them as to get to as many of them. It's possible for some of the more advanced features and topics. So that's it began enjoy the week one with it, the deadline for the projects. So I said the deadline on Fridays every week, and I realized that something that's kind of difficult for a lot of you. We have full time jobs, so feel free to take your time with the projects. And if you don't finish it before the start of the next week. That's fine. We might not be able to comment and talk about your projects, but it's totally up to you. So you can. You can take a class at your own pace, Okay, so that's so let's get started. 3. Import Custom Package: So that's start a new project for this week. But a file new project. And there's the name skills Share week two. Okay, you can leave these contract. We want a clean project. Takes a minute for unity to start any project. But now we have a new project here. Great. Okay, now that's install playmaker. So the way this works is playmaker is a plugging for on add on to unity. So it's gonna add more features to the unity editor that we could use and the benefit of playmakers, one of the main benefit for us in this class as that allows you to create interactions on movement of objects without going into Cody. And I think that that is a powerful tool, especially for those of us who didn't come from a technical background. So So that's go ahead and do that. Make sure you've downloaded the student version from the website, and I want to think Alex and errand for their generosity for this class. Right. Okay, so it's good to assets import package. Right? So what you want to do is you want to import a playmaker package custom package. So down here you have all these packages that comes with unity. So these packages that come with unity, but we want a custom one. We wanted one that we just downloaded so called a custom package, and we are going to find that file that you've done with it. Okay, so you find your file and you open it, so it's gonna have a dot unity package, uh, sort of phone, Amy. Never. But if you might be hidden for you, But anyway, find this file, open it up, and it's going to import all these files into your unity just for this package. So here's another thing about these add ons is whenever you import one, it is only imported to a specific project. If you I only want to use playmaker for one project, but not the other. That's totally fine. You're not changing your unity publication in any significant way. In that sense, it's project specific. So we're gonna import this into this particular project. Click on import. It might take some time for the software to integrate to. Okay, Now we have You can see that before we didn't have anything in our assets folder because we haven't added anything yet, but now we have three new folders here, and these are all essential files for Playmaker. And then, as you can see, we now have a playmaker photo going to the photo for a few more photos and different things inside. But we're not gonna worry about that for now. That's how you install plugging in that on or a playmaker. And if you have playmaker, let's say if you decided this is a tool for you, you can also find it on the assets store. So you go to the assets story as we talked about last week. This is where you find all these assets. You can't even point. Um, and if you go slow but slow today, but yeah, I usually just have search play here, or if you usually use to grow down, you'll find it. It's it's fairly popular. I certainly do that. And, um, you can purchase this here as well, and then you will be the same process, purchase, download and then import to your project. So another thing you can do as once he started collecting assets from the assets story can click on this button here, download manager and find all the assets that you bought and then you can important from here. Let's say I want to import, you know, the Spartan that I can just important again, You know, anything that you thought before he's gonna show up here. 4. Open Up PlayMaker UI: we have playmaker and starred that. See what I can do with it? Let me just give you a quick introduction of that. You I the interface. Uh, but first of all, that's create Cube. Yeah, I want to be a Seymour female objects in the scene that I wouldn't play around with and again a plane. This is kind of like my default said about always. I like to dio, you know, some curious floor gives us some sort of perspective, right? And then what else do I need you like, don't I? Okay, again, directional light. Let's move this out of the way. So I don't accidentally click on it, Trey. And then let's move these things up a bit. So one thing you can do you can do to To select objects in the scene, you can click on them kind quicken track. So, like we can click on the subject and hold on, hold down, command or control. And then so, like another one for the select. So you can still have multiple ones. Political objects that way in the scene, See? Select peacefully. Okay. I'm gonna move these up a little bit because he looks like my camera is not seeing these objects. Just check where things are. It's not essential right now, but I like to sit said this up so we can see what we're doing. Okay, I think that that's good. Okay. So to use Playmaker, you click on the playmaker button up here. And this is where you will see all the different items. A different menu items for playmaker ones. You've seen star Playmaker. You should see this on your menu, boy. And let's go into Playmaker Editor. We're going to skip stirs for now. There are different resource is you can use. She want to and more about playmaking. But that's close. That and this is the playmaker you are that you're going to spend a lot of time with on the left hand side. This is where you designed your interactions, how things go from one state to the other, will talk about what? Her status in the next video. But let me just give you an idea how what this tool looks like. And on the right hand side, this is where you will create interactions. So on the left inside think of it as where you organize things on the right hand side. The actual interactions, right? And what I like to do is I'd like to put playmaker into a tab like that. So? So I keep everything in the same interface in the same editor, and simply because here, I'm going to save this layout. Okay? Okay. Now you have access to play maker before we continue. I want to talk about how the concept behind playmaker and how states word behind the scene when I take you behind the scenes, how things would sort of requires a different types of thinking and let's just do that now . 5. What is a FSM (Finite State Machine): So the before we started using Playmaker, we need to talk about the idea of a finite state machine, which is also known as some people call it Finally, something called State Machine. And this is a concept that I when I was learning about it, I found it quite difficult to grasp. So I'm going to try to explain it in a simple with simple terms as much as possible. I tried looking it up on Wikipedia, and it was just really difficult to understand. So I'm going to just try to explain it as simple as possible and then hopefully you guys will understand. So the idea of a state is basically what the object is doing. I think that's the easiest for you to understand it. So, for example, we have this person here, a bus stop. And what is this guy doing? Is waiting. So let's say the state that he is in his the weights thing. Now, over here. Say Okay, this bus came. Yeah, minimalistic. But so this post came. Now this guy is gonna get on the bus. Right? So that's what we're bite. Okay. Now he is called walking, walking to the bus, right? So he's stayed. Changes from his weighing state is walking state, right? So now is walking towards the bus. And once he's inside the bus, let's pretend that is here. I say that France teacher and now his here is sins is driving us right so you can kind of understand that states are basically just what an object a person character is doing. So that's the States, and that's used real life. Example. If you call me, you have instead of long is at this. Currently he's closed. Getting close state now the bulk of his name Open state with State off locker open. So it's got to states. I noticed there is a tradition event that happens between the states went from a close thing open state moment. There's does my head this So between open state, there's event, which is me opening, so it just stay in between states. There's you bet. So this is something now in the city. Shape now shape state. In between states, there is transitioning defect, which is me giving, meaning the player giving shape, shape stay. That's finite. Statement 6. PlayMaker Example – Start State, Action Browser, Rotate, Translate, Wait, Finish: Now we understand what a finite state machine is. Let's at those state machines into the game so we can use it to create interactions and different moving things around. That's try moving things around. Okay, so let's click on this cube. Right? So we have to keep selected. And what I want to do now is I just want to create emotion. I want to keep to move when the game starts. How do you do that? That's good to play maker, right? Click to add half s and which is finite state machine right now have state one. You can change the name to something else, okay? And there are a lot of different parts in playmaker that we can talk about. But instead of going through them right now, that's create something that we can see and see it moving. And through that exercise, hopefully you got to get a sense of how this works. So we were. What we want to do is we want to start moving this cube when the game starts. Now in the state tab, click on the hash it browser and you'll be presented with a list of actions here and playmaker companies a lot of different actions for you to use. And this is great, because instead of having to manually right out or co these actions in programming language in C sharp JavaScript, you just drag and drop these into your state. So we're just going to do something really simple, right? So we're gonna go to transform. Now, remember, transform is this little component here on your object. Every object has a transform. It decides the position and rotation and scare off the object. Now we want to move this object, which means we will be changing its position. Right? So what we need now is in action. That's in the transform category, right? So when you open up the actions browser to have all these different categories, right, so it's gonna transform. And what will you wanted? Teoh is that's do rotate. Actually. Now that's dio. Yeah, let's do transform. Translate. OK, so we're going to just move. There's object alone. The hacks Texas. What translate means is basically just moves enough jug on the three axes so you can click on translate and click on add action to state. Or you can simply double click on it. Now that we have translate this action translate in the state which is named start to moving, right. So game object used owner. Which means we're gonna move this owner object here, Cube. And let's just say we're gonna translate this. Good put down one. So that's gonna be how much to move on the X axis. Now, this might be too much. That's that. See how that looks came. And we wanted to make one unit per second and every friend. Now, I'm going to talk about this next, but just keep make sure that these two are checked and then that's Ted play. Now you can see that there another three buttons here on the playmaker. Kind of that. The same as the three here stars play. You can see that now this cube is moving. Now we have something that moves in our game. Great. So that's a basic example of how this works. Now, if we do that again and and look at the object in the scene of you could play and now this object is moving along the X axis at a speed of one unit per second, as we just defined in a translate action. Come over here, Translate. Now we only have one state for this two because that's all we wanted to do now is we wanted to move in this one direction. The next example will have will have what's tried to have multiple states that you can you can play with. I also noticed there is a start transition. So every single playmaker ffs and has a starting state, which means it simply means when the game starts, what's the state the objects in? So let's say if I can't another state here, and I will say this is right and I can make this into a start state. So when the game starts, instead of going into this state and start moving, this cube is gonna go to Rotate State. It doesn't actually do anything right now, but I'm gonna dio see if I transfers to click on the action browser again and I want it Rotate right. So there is and actually called real. Take another thing. Another thing you can do is do a search rotate and again, trends from category have rotate, uh, quick on this game. Object use owner. The owner is Q which is Let's keep here. And that's just say we'll turn around. Why 15 to 15 and then prove per second that play, Notice how there's no longer moving. That's simply rotating. And if we check click out playmaker, you can see that the rotate status highlighted with this green border. That means this state is active and you can also see that here is no tape. That's the state. We're in. Another place you can see this is by default. In the game of you, you'll see the state of the object as well. Now what if we wanted to switch the state? What we can do is okay. Let's say if I want this object real tape for three seconds and then start moving in the X direction. What we can do is let's add an event, a transition event finished, okay and click on this event, and then track tracked us to the next state. You can also move this around Well. This is going to do is once when when this object is in the rotates state, then there's an event happens. Then it's going to go to the start moving state, which will move the Cube. What we need to do here is we need to add one more action, right? So I'm going to add his action called weight Action in the time category. Double click on it, and I'm going to say wait three seconds. And when After you waited, you've waited three seconds. Finished event select. Finished. Right. So the object is going to stay in this state and rotate for three seconds. And once that three second is up, it's going to send any rent finished, and then it's gonna go to finished. Which leads is to start moving. That's how this works completely. Now we're in the Rotate State could see that rotating and now is moving. That might be a bit too fast. That's changed that, Teoh. 10 seconds. Okay, start. We're in rotate states rotating here. It's gonna do that for 10 seconds, and there it starts to move. I can see that we went from a rotate state to start moving state. And if you go back to the scene, let's continue moving because it's being moved state and we have this action that tells the cable to keep moving on. The expects is so that's the first example has revealed what we've just done again just to make sure everyone's following this train. So first I'm moving the states around so that we can. It's a little organized for me, right? So first we created state, different states that we think this cube is going to be in right. So we want to keep to have two states. One is when it's rotating and one is one is moving. I'm just gonna meet changes to me, sir. It's more consistent. Rotate and move. So So the cube does two things. That it's either in the rotating state or removing state and to move between states. When the defense as we were a couple of videos ago, we were talking about the concept of state machine, where you have states of doctoring different states, and in between state, you have events that transfers you from what state to the next. So in this simple example, we have two finished event that simply says once this object is activated, though, that came starts. Once you're in the state, 10 seconds, then we're gonna go to the finished event, and from the finished event, we're going to go to the move state. Now that's imagine if we have 1/3 state that says Stop and it's simply does nothing. We don't want it to do anything. We just want to keep to stop doing anything that is doing. I can change this to say, OK, one you've rotated for 10 seconds. See how I just moved? I click on the event and drag to a different state. So when you rotated for 10 seconds, go to the finished event and we're gonna go to the stop state. At this point, the Cuba stop during anything because there's no action here. Cable is simply going to sit there and not do anything right. So let's see how that works. I'm gonna keep this here so you can see states being transferred right? Okay, so now it's rotating. It's in a rotate state. We're gonna wait for 10 seconds and narrates in a stop state. So it's not doing anything because there's no action. It's not moving. It's time to meet. I stayed now. How do we streamed all three of them together, right? What weaken Dio has I'm going to say we'll take when you finish ltalian, go to move And when you finished moving, go to stop. And when you stop for a few seconds to go back to real tight And how do we do that? You can add same thing. We're gonna add a weight action and say you for five seconds and go to the finish event, and now it's gonna go to stop. And again, I'm gonna at await action. And instead of going to the action browser and find the weight action, I'm going to simply copy to click on weight and copy selected action, go to the next state with stop state right click and pays action. You can also do It was control C and Control V or committed seeking command. Be on the back, right? So in the stop state, it doesn't do anything. You simply wait for five seconds and then finish on goes to to finished event. Now it says, finish event finished. These two does not have to match. This could be this event could have a different name, and then we can go into that data. We have customized custom names for these events, but let's see how that looks. So it's rotating 10 seconds, but long Now it's moving. Let's go to the scene. It's moving now It's stopped. It has stopped. I went to the stop view and I was retaining again pastas for a second, so you can always pause the game using this. But here, I'm going to move playmaker down here so we can see everything working together since the game. You to the actually tell us much about going on. Pause the game. Okay, see that it's in the Rotate State. It's rotating, harassing move, state moving. Now it's in a stop state for another five seconds, and it's just gonna keep going. Keep looping between these three states that we have defined moving again and then five seconds later, it's now in the stop state. Okay, so that's a simple state. And another thing I would've mentioned is now you have this icon here that has this. It's a Chinese character. This is play, which is playmakers. Icahn. So it just tells you which objects have a playmate component and also become to your inspector. You can see that there isn't the playmaker F s M component here as well. And this is, as we mentioned earlier. Unity is a component based engine. So when you add a playmaker, component shows up. You, inspector, you can change the name of this component. Andi. We'll talk about template here, and you can have some more information about state. One nice thing about Playmaker is you can add multiple states to one object, so each state could be controlling a different aspect off the objects of, for example, this state what we've just created. It's simply rotates, moves and stop so we can say this has a moving Yeah, and we can add another one. See, have just added another playmaker. State machine. Andi. That's imagine if I am going to have some player control I can still, captain. I'm going to define all my controls in this state machine, and it's it's going to separate thesis so your state machine doesn't get too crazy. When I first started, I have faced state machine with 2030 different states and and that was really hard to manage. But for now, that's not That's not worried about God. It's removed this okay, 7. Frame, Update, Run-time: so notice how we have this option here on the actions are there on the rotate action one translate action that you can check or uncheck this option called every frame. I want to talk quickly about the concept of frame rates, frames so very similar to films. One. You see figure games playing on a screen. You have different friends that's being presented to you, right? So if he if you're familiar with games, sometimes you hear people say something is running at 30 friends per 2nd 60 friends per second would 600.4 friends per second. Um, and that simply means in once again, how many different images are presented to you and another way of thinking about it as a frame has a unit of. It's almost a unit of progress in the game, right? So that game goes from when you first start the game. You're at frame one, and when you and asked, the game continues. It starts to go from from one from two from three from four from five, and each frame has really short. But that's that's how it works. It's you basically think of it. Think of a NASA measure of progress of the game, right? So whenever you start, it's always first frame and then you go from there and continues to increase the number. So the idea of every frame here is that you want to rotate 15 degrees every time. There is a progress in again an update every time that game is updated. So if if this is a little bit foreign to you, just think of it as a matter of almost like a measure of time. You know it's not exactly time, but just to make it easier to understand, can think of it as the major of time of progress, even in the game. Now. The reason why we want to check this is because we want the object to continue to rotate, because if we don't have every frame, then this action will only be thats action will only real. Take the object once you're only rotated, object by 15 degrees and then it's done. I'm sorry it's not actually degrees, but it's gonna be rotating the object by 15 units and then you will finish this action and go to the next one. Let me demonstrate that for you. So this is our original set up or have every frame. Right? So it's rotating, and it's going to rotate for 10 seconds as we set it up. I'm gonna stop it now if we own check every frame, pay very close attention to this Keep. Okay, press start. It rotated a little bit, and then it just stopped right, and it just stops and wait there. All right, So, by the way, I just noticed my mistake. This is Degrees, uh, well, a community. There are two different systems for rotation, and And this one here, that is why angle? So it's 15 degrees anyways, so the, um frame is basically if you have, whenever you see every frame you have to think about do you want this action to be continues? Do you want the object to do this action continuously? And in our example, we want after to continue rotating each time 15 degrees, 15 degrees each time. We wanted to continue rotating until we are out of this state. If you don't have every friend check is only going to do this once. Okay? So just if you don't quite understand the concept of frames yet, just remember that sort of through off thumb is if you want this thing to continue to have this action, check every frame and Sen thinker with move. If you don't have every frame that it's only going to move one unit on the X axis once. And then he was Just stop. Let me demonstrate that. And also, I'm just going to make a quick change here, I think. 10 seconds to own three. Great. Okay, it's were training is in the road. Take state as soon as it gets to move state. And if you caught that, but it moved once and then it just stopped. Do not continue moving in that direction. That's attention again, rotating just a quick snap and then it stopped. Now, if I start, just stop the game again if we have every frame. So this is the desired behavior you have continuous movement, continues rotation. Look at this movement now and then stop. And then again, continuous rotation, every framework rotating 15 degrees every frame, and there were moving one unit, every frame. So that's the concept of frames. Another thing I want to quickly mention is concept of run time. So when you're editing the game. You can change the position of objects, right? But this has no well, this does not affect how the object moves in the game. Right? So we're moving alone. What are the X axis here? But the game is not running. So this is editor time. You were editing. This object is moving ahead of time because your game is not running. When the object is moving while the game is running, we call that a wrong time, right? So? So this object is currently moving. They were on time. Um, it's just when you're going to see this term continuously, as you continue to learn about game development, and it's it's good to know what it means. It simply means at run time means something that's happened when the game is running when the game is running. So everything that's happening now is run time because the game is you can see with playing the game when the game is not running that we're not. This is not run time, Even though you can see just keep moving. This is not a long time. Just a quick note on that 8. Action Browser, Mouse Down Event: Let's take a look at the action browser again and try a few more different types of actions just to give you a taste of what are some of the things that you can do with Playmaker? I think this time I'm gonna do something. Wars. There's four object case. I select trick means floor and go to your playmaker Todd, Right click at State Machine. Okay, let's go to action browsing. Okay, let me just quickly go through some of these cat categories so you know what you can do with this? Animate variables will talk about very close in the next video. But here you can decide how you want to change the venue variables, and you can do them with curves animation. So if you watch the previous view about setting up animations or the animation systems in the unity, you can use actions in this category to to manage that application is so when you build a game, the game is a location. When you build a mobile app, the mobile APP is in the application. So this is where you can manage that. You can say Well, when you click this button, we're gonna quit the application. Take a screen shot off the game. Audio. Talk about a deal soon. Carol Writing Have some actions related to camera character controller Talk brothers when we start creating player input color so one of the variables can be color, and then you can change colors in various different ways. Device as if you are creating a game for a mobile device. Then you have different times of controls. You can. You can have different types of actions that would manage that touch your friends have location, information, and that sort of thing affects. You don't really used these too much, but they kind of nice to have when you need some quick effects on objects. Game object. This is a little more complicated, but what Basically, you can manage how the game objects Here are how many people you did it, where had No, you can't destroy them. You can activate you activate them. We can have components doing wrong time. So when the game is running, you can program the game to do these things for you and said, If right now you do these manually, Uh, during editor time, no, Sometimes it makes sense to do? I had a run time. Um, I don't usually use these actions. We use other tools for green. Which is that you I inside of your game. But you can if you want to use a default unity you are. You can You can manage them here using actions here. Input. Obviously, a big one will talk about this in this video. Let me just go through the categories first. This is where you can control. Command is using which keys and how the keys interact with the world. You can control most location, mouse buttons and everything between is a powerful tool for animating the transform. So deals mostly with the position on the rotation in scaling off the object. But it has very nice effects that you can use. We could talk about the invader level when you have multiple scenes. How do you go from one to the other? All rights? See if there's anything that we could use way materials. We talk about materials earlier. You can change your material during the game. So maybe we'll use this for for this example. Math. If you have variables, you can use the actions here too, to sort of calculate how the variables should be updated. So some of these you probably don't know where. For now. Player press will talk about this a little bit later. This is basically the safe data for your game. That's a high school, local high score or you want to track how far the players progressed in the game. But all are inside player press. We sort of talked about renders and so we can have a knack Shin that says, OK, when the game is that this point where the character comes to this point, change the skybox to a different ones, change from daytime to nighttime and then you will see that during the game Scream control when I'm gonna worry about that, sits right of going up to any sort of Kolding. But if you have scripts that you wanna interact with, playmaker, this is what you will do. The actions were used state machine, similar kind of states. If you have multiple state machines across different objects or witnessed them of drug, you use these actions to be direct with him strings time. We talked about time a little bit with the weight. Actually, anything related to time. It's in this category. Transform a big Juan. This is how you manipulate objects in the scene tips, a position in rotation and scaling, and a nice one that I always use a smooth look at. So you can have an object that looks at another object continuously. But don't worry about it. For now, we're not using it yet. Back to three sort of deals with Hankins. Very three. Variable. We'll talk about that end of it, so it's just a quick already off the actions. And let's see another thing. I didn't mention this. When you click on an action, you'll see this little preview window contend us off. Usually gone basically gives you a quick glance at what are some of the options inside the action, Right, so some of these are fairly complex. For example, if you go to a night train action, then have a lot of different variables that you can tweak, some of them are fairly simple. Um, right, for example, could you quit that there's no option just quits the application right? And another thing that you could do, and this is very handy, is when you are looking at an action. You can click on this the button here, how button and go to that plane. Make a website and explains what this action does. So I was looking to take screenshot when I click on that, goes to take a screenshot action brief description and explained explanation off the different options inside his action. And this is great because sometimes you are not sure what that does or how to use these parables. Various options Click on that. The button that's just explains everything to you. So that's very handy. And you can access that from here or close action. Bears it to go back to our cube. Some actions there, Uh, sir, on the state in action that's in the state. You also have this button that could click on your open him the browser and go to the U for page so you can learn a bit more prevail this particular action. Okay, so that's make this so that whenever with click, whenever the player clicks on the floor here we changed the color. So that's a friend looking dio now the first state soaps. And now again we're on the floor object, And if you don't have a state machine, then make sure you had it by right clicking here. I'm gonna do it again. I'm gonna remove playmakers. And now this is just plain good for your playmaker at a time. Right? Click. Add state machine. I'm gonna call the first day. So it's just titling. It's not doing anything. Is waiting for the player to click on it. Right? So that's the ideal state, right click again and then add a second state. And here I'm going to say, Is this color So I want the game to change color when I clicked on the floor on the floor to change color. Okay, so there few few ways you can do this. That's that's designed the color state first. Okay, so we click on the action browsing. You see all the actions here. What we want to do is click on material and go to set material color contractors into the state where you can double click on it, make sure is use their only we're going to change this object, and that's just click on color. You see this little color time window and then just pick a new color. Let's go with. Great. Yeah. Okay, so that's all it does. It does state basically just set a new caller to the material that's on the floor. And how do we tested? Let's just do, um, finished state and then connected to complain. Right? So you can see that that's new color on were in ST. So basically the game. When the game first started who went to the Idol state, there was nothing in it. So it directly goes to finished event. And then from the finish, the van will go through the new college State, which says the color too green. Right now, we don't want to change the color right away. So I'm gonna delete this transition, and I'm going to add a different type of transition to right click on state, could add transition system events and then go to mouse down the train. You don't stand click on that and then connect that to your new state again, have transition system event, and then these are some of the default offense from the system. Okay, so it's traded again. Complain Right now it's in Idaho State and for click on the sky area. It doesn't do anything But if I click on the floor goes to the new College State. So mouse down, the mouse down event is triggered. Is it happens? One. You click on the object with your mouse button, right? So that's kind of cool, right? So we have this floor that changes color when we click on All right, that's what the mouse down you got does. So that's very cool. 9. PlayMaker UI Part 2 : but we have started creating some interactions, some things to move around. That's that's take a look at the playmaker interface again. I want to introduce a few more things there. So go to your playmaker editor Tab. Um, click on it and then just press space. Right? So remember us work. We mentioned the press space it will maximize to tab to full screen. Right? So if he see at my mouse curses above, inspected and then press space, we'll just maximize that view for me on this is particularly useful for playing because sometimes you have a lot of states in press space. I was just maximized view eso. First of all, you can hold out your mid of mass button and they move around. It's kind of similar to the grab tool for that in the scene view. Right? I also, if you have this thing you playmaker. So let me just go back to this view. I think biking for you'll have this many map playmaker. It sort of helps you move sort of navigate inside your state machine, even turn that on and off by clicking this button. Right? So this is this is not a complicated state machine gun turned it off. And, um, also, you have a few different options here, So notice how we have to objects with state machines Inside, Playmaker, you can click on this field here and switch to the other one. So it lists out all the objects with state machines, and also he lists out the next menu less than all the state missions on this particular object. And now we only have one state machine put object right now, so it's just gonna have one for each of our object. But that's we start having more se machines free each object that you're gonna have more here. So basically just helps you select. I was fine. Yeah, check. You wanna added or and find in state machines that you want added, You can also click on the reason button shows the reason. Help checks a ive edited Where you go, you can go back forth, right click on the back button. It goes back to the previous state machine that you rented him back and forth. You can also locked this so when I it's like a different object, see how it's locked? This view is locked to the state machine on the floor right there for sm, stay machine on floor. Even though what I'm selecting here is to Q and the Inspector is against key, but because I've blocked the view when I was when I had floor selected This does not change . If I like it and I start selecting different objects, it's gonna change depending on which objects being selected and that down here, if there is an error that say, if we have let me read, didn't delete this tradition. Now there is an error, right? This explanation might. But this notification basically shows you that. Okay, now there's a slight problem here, and you can click on it. Double click on it. You're half this pop up window here, a check well, say event not used by the state or any global traditions. What that means is scroll down. The nice thing about this is on this the editor here, you can see that there's a problem on the state from on the state, and it will show you which action is having a problem, right? So we don't have any problem with the translate stayed, but we have a problem with the weight action, and this little button shows up or not about the still icon shows up next to the one that's causing error. And the problem is, we said a finished event we used finished event. But it's not define here. We don't have it here. So again, how do we How do we fix this problem? We can simply go right click at transition, and we add this finished event back. Right? Notice how now this error icon is gone, but we still have a problem with the state. Let's check this again. Why? Says transition Missing target state. Right. So this particular transition, it's not going anywhere, right? So we define an event. But what what do we do with this event? It needs to go to another state. So every event, every transitioning event needs to go to a state, Okay, And then as soon as we connect, those two error errors were gone, says no errors. Everyone's happy. That's great. Debug various different ways. You can debug this state machine deep up simply means sometimes you. When you create interactions, you'll run into problems. You have errors, and you need to fix those errors on that. That's a process we call debugging. And this menu sort of helps. You can do different things with it. We're not gonna go into that right now, but if you are familiar with the process, that's where you would do it. And preferences different you even you can change the way Just part looks changed the way behaves, um I usually leave most things as default except for zooming. I don't usually use that. So I kind of turned that off. Um, on many man get me on the state machine. I don't usually use it, but it's a cool feature. And, uh, I think once no, we start doing more and more Wizard. Why? I wanted to get on once in a while. Teoh, Check where everything is so a lot of different options here for you to treat. But for the most part, don't worry about it. So that's some additional information home, the playmaker interface and our first and so this is similar. This is basically the same as this component here, and I usually added here anyway, so So focus on your stayed and events in your variables 10. Disable, Enable, Editing during Play Mode: and we talked about how unity is a component based engine. And if you go to the inspector, you know that you can note you can see these Phil check boxes, right? So if you uncheck this one right here at this, a Bose that object, we can see that the Cube of Jackets grayed out. It's not active. Doesn't mean that it's not in the scene. It's just not active, so you cannot see it. And it does not do anything when the game starts running, Try this in the game and, uh, the state you've checked the state machine on the Q is disabled. It's not in any state. There's nothing going on with the Cube. The game is still running. How do we know where you could cook on the floor? Just do 1/2 that new color transition, new color function there. But here's another thing we could do. We can you just turn it back on, have a stop the game. Everything we do is we can disable the floor object, and now all of a sudden there's nothing in the scene that wouldn't see even though they did there, but 20 Sebold, right? Eso so you can disable and enable activate and deactivate objects you get. What you can also do is you can the same and enable components on an object. So let's see. I have to queue and it's active, but I don't want to do anything I don't actually want it to. I don't want to rotate and move and start like with what we had doing before. Um, I just want to experiment with not having fat feature in the game. So instead of removing the playmaking component which will remove everything that I've done here, which also means I can go back to this if I change my mind, we can simply just disable that now. It's still got the component, but the component is not active, so it will not do anything with it. So if we hit play, you can see that the game is running the this compote. This playmaker component is disabled, which is also stated here. What we know the cam is running world. If you try this again, click. No changes cause the game is running, but there's nothing on cause the Cube is not having any behavior now. What we could do is, we can activate it during runtime. So we've talked about when the game is playing. It's running at run time. We can activate this, and all of a sudden it's during this thing. It's starting to go through the different states, right, Because this playmaker finite state machine is running. This component is active now. One thing you need to pay attention to their, however, is any changes you make in the game doing runtime, meaning one. The game was running, and then you make different changes to the game. When you stop the game, the changes will not apply. So none of the changes that was done during runtime it's going to remain in the game. So that's to prevent you from making mistakes that you don't actually making prevention from making changes that you don't actually want to make in the in the game. So noticed. I mean, let me just demonstrate that again, start the game. All right, so this is we have this component disabled, so it's not doing anything. See neighborhood, and then stop the game. Notice how this is reverted back to the disabled state to say vote component, but it's me. Make it activate this component play? It's Tom. It's still activated because we made the changes when the game is not running. So make sure any changes you want, mate, are you make them what the game is. Not running. But when the game was running, it's great to have the ability to experiment. It's different things just for it. For testing purposes, for prototyping purposes. So that's disabling and activating different components. Teoh. Different objects. Okay, the next thing I want to do is I want to have a little bit of sound. How do you do that? Uh, actually, let's do that in the next video. 11. Empty Game Object, Add Audio: now I don't wanna have some sound and some music in the game. How do you do that? Well, again, we all we need to do is find the old year component and added to a game object. And all of a sudden we have ordeal in a scene where audio in the game. You can do that in several different ways. You can create a new object and just add an audio component to it. Or you can add a new audio component to an existing object for background music. You probably do it on a separate object because it's playing throughout the whole game. If he that's if if there is a weapon that you are using and you want to sound to go together with the weapon that you want to sound, too to start from the position off that weapon than you probably just add a no deal component to to the object. So that's, um, that's a student. I'll demonstrate both method and you'll see what I mean. So she also introduced the idea of an empty game object. So so far we've been creating objects from the primitive models have been creating these primitive models into the game. All right, um but you can also create an empty came object. So go go to game object, create empty. And it's just gonna have the name, game object right on it. And there is no component. The only thing that past is transformed. So it has a position in the game has a rotation in the game. All right, but you can't see anything. It's not. There's nothing else, can it? It's just a set of data attached to this object going to reset quotation. Okay, Want what is that useful? For example, since now we're creating an audio component, it doesn't have to have a visual, right. People don't need to see where the sound is coming from. Although you could potentially create speaker model and then put it there. So then play. It goes close to the speaker, they can hear the music. But for now, we can just say Okay, we have this empty GAM object. It doesn't have anything in it, and we will construct a new object from here from scratch. OK, so I'm going to rename it to you ground right, and let's click on add components and that you are you and audio source. Right. So basically, this makes this object Mr An audio source. All right, so it contains an audio that but that speaker is gonna become, and we need to have an audio clip for it to play. I wanted to play. Are there a son or sound? Could be anything. Could be any any kind of standard wave file. Where? MP three file. But now I don't I don't have any music files in my scene. So again, I just say to file, But let's go to the assets during and see what we can find. Okay, So has it store. It's gonna hold you super confined. Any good free sound or music. Now, one thing you want. Oh, pay attention to it, even though for them. But this one is free. Size is fairly bag. And for the purpose of this demo, I'm going to try to find something a bit smaller. So it downloads, but faster. I can't see. I remember seeing something earlier that we can potentially use. Yeah, a bit sound. Click on this. If you can find it. Just do a search. A bit. Sounds. It's only about two back. That's great. Download and again Gonna wait for unity to import package Coming close out. Yes, a store. Okay, we have a new voter now called a bit sound. And if you click on it, you can preview by clicking on this Could see what that sounds like. Okay, so that's to sound effect. Try the explosion sound. That's cool. If you click on loop on, it's going to continue annoying. But that's good. So, um, when you try that Okay. Okay. So, um, not exactly background music type of sounds. So I'm gonna try to find another one. And I just found this one called Music by Joey. Um, I don't know what this is going to sound like, but almost as a fairly small So let's let's give that a try. And then we can use a bit Sounds for something else for sound effects. But let's just get the background using first, okay. Again in point and, uh, close assets story whenever that's done. Okay, That took a bit of time, but I think it finally finished importing. So if you go dio there's a new I just got this new photo music files and again that's preview. So So when is called Frank Drakes? Quite question. Right again, The inspector. You have various settings that can you can use for this particular file. And the nice thing about this is you can change the compression and you can change this file size. I might be handy, especially for doing a say, a mobile project. You might want to reduce the file size, but that's not where about that? Now click on background music again. So this is Theo. Empty game object that created it's missing a an audio clip. So I'm just gonna track and dropped us here. You're right. And we want to have a play on the wake. Which means when you start the game when the seat will actually says here, you know what? The scene lows will start playing this music. And also I want to look so that continues to play this music in the background. So we just didn't play, can you? Music is playing now. No. Where? Background music. Break it. So something was sound effects. All right, so now we have background music. Or maybe we want some sound. What? This kid is moving. We wanted to make certain type of sound. So click on the Cube. Actually, instead of doing that, I want to play a sound when the floor is changing color. So we when we click on the floor, I wanted to play a sound, So that's click on the floor. Click on Add component and again ordeal. Audio source Gonna collapse. This one says a little bit cleaner again. It's waiting for an audio clip. Let's go back to the eight bit sound now. I just I just want to sound that place ones one. The fluid clicked on. Yeah, let's go with that one. So click on the floor, Find our audio sword audio source and then again, drug Drop this one here now the singers we want Teoh Uncheck play on a week because we don't want it. Teoh, play this sound when the game starts. We want to play it when we click on the floor so we don't check that. Another thing I want to do is I want Teoh transfers from a 30 sound to a No. 137 It's just it's a little bit are easier to deal with, and I'm gonna do the same thing with That's one this Well, so that's kind of reimport. Yes, it predictable seconds here. Clear what that does, simply, um, to solve a problem. Sometimes when you have a sound music in the game, it's really quiet. Sometimes you need to do is just making Theo come back to this floor. So we now have a new audio sores component on the floor object, and we don't want it to play on on the weight. We don't want to play where the game starts. We want to play only when you click on it. And how do we How do we activate this? How do we tell the system to play it? What? We're gonna do it inside, playmaker. Okay, so let's go back to play maker. It's like the floor again. Gonna make bigger. Okay, so now we know that when it's and I dont stayed waits for amounts down event and as soon as we click on the floor goes mows down and the new state new colored state Okay, so first thing do we do here is changing color, and also I wanted to play a sound. So click on Action browser on its fine north you and holding employees. Double click on it. See that it's been added here again. Game up, Jack. We're gonna use owner Volume one. That's fine. One shot clip. One shot means it's gonna play it once, so we can, Um okay, so here, instead of doing that nationally, allows you to eso Play make allows you to play a sound that's not here. Like if you have a game of your get doesn't have this set up here, it's fine. Cano's will play in addition of music additional sound clip here, but we're not going. We're not using that since we already have an audio source here so that we're going to just leave that at. Not so. Don't worry about that. And hit, play object. So So So we don't have so many so much going on. Try that again. Okay, now we don't have the background music, and when I click on the floor, place the sound here and that was triggered by this action. Are you play in this simply place Whatever is on this. What? What audio clip is attached to this particular object 12. Lights On and Off – Toggle, Key Down: Now we know how to detect a mouse left, but click on an object. What are some of the other interactions we can create? Let's try this. That's try using a key press to turn on enough the light. So click on the direction of light Right click had state machine and again I'm gonna say go or way anything can add a description. Pressure is too. I told the description is waiting for him for it. And what I want to do is finally an input event. Action. Okay, so get key down since an event when a key is pressed Sounds like something I want to do. So stepping quickly and there are a lot of keys here you can select. I'm gonna just dio see space sense event. Now there's no event here for us to th so I'm going to create a custom event. So remember how when we right click on the state, you have the's system events that you can use. These are default events that comes with playmaker on some of these A really useful you probably use over and over again. But now what we want to do is creating a custom event. And by the way, I had a link to the syllabus so we can learn more about some of these system defense. But for now, let's go to event, and I'm gonna have an event called. It's called Switch, Frank. Now, when I right click and go to at transition, have any event that I can choose called switch off. Okay, now, that's a switch off your friend that I just created and come back to the state. Come back to the action. What? Space is pressed down the key town space. We're gonna send the switch off event, okay? And credit. And you create a new state called Thank by and then I'm gonna connect to. So the switch off event. Well, go to the lights off state. Hear what I want to do is turn off the light. So action browsing soup is any passion. It's the lighting break. Show that say, set the intensity was selected the wrong one again. You can always remove that from here. Click on this button here and your actions get click on action browser light once. Okay, Intensity. Great. I'm just gonna set this 20 and that's it. So Let's try this Could play. Okay, Now we're in the idle state, Miss Build. That would That's how we got that now and, uh, press the space bar Those lights off. And now the intensity of the light is zero so dark. Now I want to make this into a tuggle. Right? So I wanted to Whenever I pressed, the space bar goes from on to off. And then if it's off, I wanted to go to turn on the light when I press a button. So that's very simple to do in. Just fix that. Okay, So once we press the space bar, it goes to switch off lights off. So what we need here? It's another event similar to this. In another action, I'm gonna copy this click on this copy, selected action and paste it care. And I'm going to go into changed the event name. Actually, I'm just gonna such on something right click at transition. Now we have to switch on event, and I'm going Teoh, switch on. So where you press space bar? It's gonna send the event switch on. And what that means is he's gonna go back to the first day and Now I'm going to change the name from Idaho to what? Okay. Very good and similar to those we need to set the intensity back to the original level, which is five. Sit here. Copy this. Go to the state, the prince and paste the action. Now, another cool thing you can do is you can move. Could rearrange the actions to decide which actually wouldn't do first. And just for consistency. I'm going to say set the light intensity first, and then I'm gonna set it back to 0.5. Okay, I was trying start the game, and sometimes you wanna just quick click on the game view. So that input. So the system knows you're controlling the game and press space. The space boy turns off the light and you can see that the lights off state impressed That again goes back two lights on. So you can white enough like that. It's very easy to set up very quickly. Can bring a toggle like that. You can You can basically use the same structure for anything us have with single kind of feature. Like I could do a door that opens and closes on a light switch. It's an obvious one. Um, any sort of on enough sort of mechanism to you to use a single center? 13. Play Mode Tint: one thing I forgot to mention previously was that remember we said that if you are, if the game is running, say it came is running and you make changes to the scene. So I had a few more come checks. None of this is gonna be safe. None of these changes are gonna be saved when the game it's stopped. When I stopped the game, that cube is gone and floors back to where it waas so to, uh, help us avoid this problem. Sometimes we do forget if the game is running or not, go to preferences, right. So preferences could have colors. And then in the general area, play Mel tent. Chance does two more obvious Call it still dark red. Now, whenever you play, I can see that everything. His I got this red color. So So you know they're okay now. I mean, plate, man, don't make any changes to the scene. All right? Diffuse it. So you can use this to sort of prevent yourself from from dealing with this potential problem. I like Teoh. Just send it back to where it was. Um, for now, maybe. Maybe a little bit of pregnancy. Nice think that read it was a bit too aggressive, But see now light pain coming. That's fine and sort of keeps me enough warning, but it doesn't prevent me from seeing what's going on.