- [Instructor] So far we've got an animation of a bubble popping on our screen. Which is great, but the game works by presenting a bunch of bubbles that haven't been popped yet, and then allowing the user to click on them to pop them. So we really need a bubble in an unpopped state. You might think that's just as simple as dragging the first bubble sprite onto the screen, and you'd be half-right. We do need to do some extra things to it though. So let's go ahead and drag the first bubble sprite out onto the screen, and I'll put it just to the left of our animation. And now in order to make this work properly, I need this to be an animation too.
But all I really need is a one frame animation with just the bubble in it. So we'll go ahead and make this with the bubble frame selected here, I'm going to go up to the Animation tab. Again if you don't see that, you can go to Window, and select Animation, or just press Control + Six to bring up the Animation tab. You can see the message in the window says that we can start animating that particular bubble. So I'm going to click Create here. Just as before, it's going to give me the opportunity to create a new animation clip.
So I'm going to call this one BubbleUnpopped. And click Save. And now I've got an animation, but nothing in it. So I do need to go ahead and add something to it. Now the way the animation system works in Unity, generally is that you can actually record your animation if you want to. If I switch back to the scene, I could at this stage drag this bubble around and animate it on the screen that way. Your visual indicator for this is that your Play buttons have turned red. And so that indicates that it's actually recording the actions that you're doing as you're moving and changing things on the bubble.
So if I resized it, rotated it, did anything like that to it then that animation would be recorded in the animation window. But in our case, we don't really want to do any of that. We just want to make an animation with one frame in it. So let me switch back over to Animation. And I'm going to add a property to animate. You can animate anything on the game object. Which in its most basic form at this stage, is going to be a transform, which defines its position, rotation and scale. Or the Sprite Renderer, which has all of the properties that you would expect in it for an image.
I'll just select Sprite down at the bottom. And mine's a little clipped here, so I'm going to scroll over and I'm going to press the plus sign here to add that as an animation property. This would normally be useful if you want to switch your sprite out with something else. But in this case, I really don't. Now what you can see here is that we have two keyframes with the bubble in it. I'm not actually going to make any changes to this. I'm just going to leave it as-is. I'm going to turn off the recording by pressing the Play button here. And when I do that, it will turn black again. What I have is a bubble that's popping, and a bubble that's not popping.
And this is what I want, because in the next video we're going to make a state machine that allows you to easily toggle between these two states based on an event. Before moving on, I'll go ahead and stop my game.
Instructor Bruce Van Horn walks through the workflows and tools that you'll need to create stellar games, and helps you get acquainted with these new concepts by putting together a project: a simple game that allows users to pop bubbles. As he helps you build this rather straightforward game, Bruce demonstrates most of the tools that you'll use in Unity to create games, as well as a wide variety of techniques. Learn how to set up Unity, set your IDE preferences, work with variables and functions, import assets, add the finishing touches to a game, and more.
- Setting up Unity and IDE preferences
- Setting up a project
- Importing assets
- Making a bubble pop animation
- Adding a bubble control script
- Cleaning up a game
- Adding a game controller
- Referencing the game controller
- Publishing to standalone targets
- Publishing to WebGL