Develop a 2D Space Runner game in Unity | SandS Arts | Skillshare

Develop a 2D Space Runner game in Unity

SandS Arts, Game developer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
14 Lessons (1h 56m)
    • 1. Overview

      2:44
    • 2. Where to ask doubts ?

      2:37
    • 3. Where to support me ?

      1:29
    • 4. Project setup with player animation by using unity's inbuilt 2D animation packages

      17:05
    • 5. Creating a scrolling background

      7:21
    • 6. Setting up Player Controller

      18:09
    • 7. Lets spawn obstacles !

      12:47
    • 8. Obstacle Mover

      5:52
    • 9. Collisions

      11:05
    • 10. Setting up UI's

      12:49
    • 11. Setting up Audio

      5:42
    • 12. Setting up particle system and playing audio when player hit obstacles

      4:23
    • 13. Highscore Manager

      8:00
    • 14. Building our game

      5:45

About This Class

Hey game developers !

In this course i will be teaching you to develop a 2D space runner game in unity.

By the end of this course we should be able to develop many games.

We will implement Applovin Ad's for our game.

Download the UI's from here - https://tastygraph.itch.io/spacerunnerart

Join my discord server - Click here

Discord invite link - https://discord.gg/ZV2KZb5

Patreon link- https://www.patreon.com/SandSArts

My website link - sandsarts.itch.io

PayPal - https://www.paypal.me/shashikala7

PayPal (email) - [email protected]

Transcripts

1. Overview: Hey, game develop owes to Shankill from San Socks and this goes, you'll learn how to develop a to re space run again like this Before taking the course. Make sure you know the basics off unity and she shop in this game will be creating so many things. Therefore, big notes will come to know so many things related to game development on They will be able to build their own game after completion of the course. Learning about fax males Clear references. Destroying background loading screens Audio Barry Full rights By using you. Give your packages on the animal rights inside community system six points on men. Move anything in the strips, for example. You can order the number of objects too strong in a particular level. The time between Chornovil be that tea, please. Bakelite with something. If you want me to have somethingto school, you can see I way have any doubt and it goes all you want about me All you want in reading . You can ask me dieting pills here. Looks like you can ask me on my discourse. Expressed that enough. Like Watsa really can share the stream so that begins can be on call. Just wear found by you. You're dreaming. I'm enjoying myself. You can teach you something 2. Where to ask doubts ?: Hey, game. They'll oppose the Shankill from san socks. In this video, we'll take a look at where you can cloud for your doubts with me when you enrolled in the course. I don't do community on. Take on. Ask a question. Type your question on Glick Post for faster Reply disco. Discard up dot com. Create your account By clicking on this button, you need to just enter your email address on, you know, to enter the password for your discord accounts. This court is a chatting up similar to water. Here. We can discuss things related to game development on. You can clarify your doubts over here after you sign in to join my Celo. Just go ahead and click on this place button Select, Join a Sobel on over here, Type this league. Don't worry. This link will be available in the course description. Just copy that on base it over here are that it will be in my Flink on. Then create your account to join my silver. If you type this link over here, just click. Join on, then you'll be joined to my server. Now take on this developing story space run a game in unity, which has stream or options there, select help on then you. You can type your doubts so that I are. Other developers will clarify it. If you want to chat with me or other game developers, just click on SAT on Type your message. You'll not be allowed to enter this particular channel because I have to add your role so that you will be able tow access this particular channel if I want to give you a role just just and lasting science arts. Click on sat with sense on over here you type at Shawshank Creator off sand socks on. Then type your name, which is seem as your skill chur account name on. Then type the course name or the class name. That's it when I will be on line. I love you rule so that you can access this particular channel or a particular channel, which has same name as the cause Me. If you'd like to follow me on skills here, you can do that. If you complete my course or a class, you can just tell your review as it helps me a lot. Thanks for watching 3. Where to support me ?: Hey, give them both. So Shankill from San Sauce and this video will take a look at how you can support me to create more tutorials. First, if you like my way of teaching on want to see more classes or courses, just follow me by clicking this follow. But then you can also support me financially. One waste by going to my website. Sansa. It's not It's not I o on on my website, you can click on any off my game, for example, shape. It's here. If you click the download button, a window will pop up, asking you for the support over here. You can enter the desired amount on Rosie are. You can go to people like me slash testicle a seven on their support. Me. You can even transfer money to my PayPal account by using our email. But is she? She promotes seven at gmail dot com. Are Goto patriot on your corn slash stance? Odds on their support. Me are goto patriot on your corn slash stance. Odds then become a patri on. After that, you can support me through patri on in Patriarch. You can support me or donate me monthly for the tutorials I make. You can cancel it at any time. You can also support me by joining my discourse server, which enables me to grow my server. So in these ways, you can support me to create more tutorials. Thanks for watching. 4. Project setup with player animation by using unity's inbuilt 2D animation packages: Hey, game duel. Oppose So Sankyo from San Salts and this video will set up a project in this game. I'll be using some sprites. You can't download them by going to tasty grass. Not it's not ill are simply billing in the description special. Thanks to a lethal of its Who designed sprites for this course, this is his website. Then take on Space Runner art. Take on download now button. If you want to create the artist, just enter the amount that you want a credit on. Proceed if you want to download this for free disk clicked this next it says No tanks. Just take me to the downloads on, then download Dizzy. After downloading, you'll get the ZIP file. So in order to open this, you need to either. And so you need to either install Win Ra are wins. After installing this double click on it on then dragon. Drop this folder into the destiny. Now go ahead and create a new unity project. Select Julie and that your project name on it. Great, but I have already created a project, so I'll open it now. We'll drag and drop the folder inside assets on Ben, click on space from Art here. You can see that this particular sprite has so many strides in it. When we drag and drop it inside hierarchy, it just brings all this rights. Now we don't want all this price at the same time. We want this particular sprite as a separate one. We want all the scribes separated. Therefore will select the Sprite on Select Sprite. More to multiple on hit apply. Then we'll go Sprite a little. We'll select slice on hit slice Now you can actually see that displaced has been separated if it has not separated. Currently, the selected on a tradition after you are satisfied with the slicing Just hit Apply. Now, when I close this, we can see that the sprites has been separated and now we can actually drag and drop the particular sprite that we need. This right is our player in again. We want a player to run, which means we need to animate, uh, player toe animate to re sprites and unity. Going to impose some packages for that will go out the window practice manager select all packages on here, select soap review packages, then click on through the animation on click install do the same for to the high K onto repeatedly important. I have installed all these packages, so I close the window. Now click on Clear People's On, then take on Stride Editor or here select skinning editor. In order to animate a player we need to create some bones. First will trade bone for this body, so I'll hide all the sprites except the body. I had a great bone on over here. All credit to boot left like to create a bull left leg again to create another bone on. Then right click to finish. Go to pray because Double Cledus applied to select it. Goto auto geometry and those subdivide as one on degenerate for selected this. Then these geometry, so that we can animate, are slight If you increase the subdivide it device. The sprite into so many parts just said it to one on his agenda for selected. Now we'll click on visibility I all this price except the left arm on. Now we'll double click it to select will hit Great Boon on now. When we moved this particular bone really toe also move the hand. So for that really to connect this particular bowl on the bone that we create over here for the hand, right? So therefore, I'll hide the body I create ball on. Then I'll click on this Red bull on here. You can see this green line which will be connected to the bone that we create. Now I create two bones, right? Take to finish writing again, as I only want these two bones to move and I move this particular bull. Now, I got visibility done off all this price, except right on. I also need to move right on when I moved in body. So I like great boon on I double click postal at this particular sprites. Then I'll take on this Red Bull to connect the bones that we're going to create. Now I create two bones, rightly to finish. Now I'll goto visibility. I'll hide all the bulls on all this price except left leg. I double click it to select as it create Boone on a great two bones Over here. I left late to finish. I was in a court of geometry and hidden agenda for selected. I'll disable everything. I hide everything except right leg on. I'm gonna create two bones over here, right? People finish. We'll go out of geometry and generate for selected. I'll hide all the things except the head Andan create only one morning with you. I'll double click to select this pride at its 100 for selected now. Well, I'm hide all the things on now. Yes, we rotate the red one. You can see that the bone's connected to the arms. Also a pit, but the arms are not rotating. It's because we had not generated Jammat e for it on even the weights. I'll disable everything except the arms. I'll select the right arm. I'll go Gorka geometry and it's great for selected. I'll do the same for this hand. Yeah, on now, when we rotate the Reds boom, we can see that the arms also debate. I think you came to know the use off or to examine Terri. Now we are ready to admit our player. Now, when you power onto any boom on, try to move your closer by left clicking, you can see that the particular Sprite is rotating on. If you sell it the five point Andrea causa, you can see that the sprites will stretch now were quick up. Life now will drag and drop feel inside Iraqi I went down, I said It size 2.2. I'll click F to focus on the player. And yes, now I think we need to arrange the parts off the players when select Body on said it's all in their 20 Well said it's artisan Lato one. Andi ordering layer off left Tom as zero because we need the left arm Toby below the body body has outer layer value greater than left out. So body ability on top of the price, which has ordered a layer less than one. We'll sell it right down. You said it's already layer to three so that it will be on top off the body as the last on top off the legs. Now we'll select left leg on Well said it's ordered near to zero as we wanted to be below the body. We're select right leg on with that. It certainly is to now we'll select this particular born on mood over. You will select this particular bone on dealing with here. I'm just arranging this price. We'll select this particular bone which is off the left on Ondo did it. I was like this ball britches off the right, Down on Generated in This now is selected on Well said it sold only one as the doctor body . Now we're ready to animate our player. So England window animation on open the animation window first will create a new in object . We'll call it Leo, where they said it's positions so that exposition will be on. The origin will drag and drop their people inside player when select player on it. Great to create an animation Inside Assets folder. I've read a new folder. I'll call it Animation on a call. The admission us. You work now in orderto animate on record the movements. Now, in order to record the animation, we need to hit the record button. First, I'll select Lee. Born off right leg on. I rotate it forwards as a leg bone on the left leg on delegated backward. I'll select bone off the right hand. I was located backward on a Senate born off the left hand, also vetted forward. After some time, I need the position of the left hand. Toby, you. So now you can see that we have some problems with the boot to fix. This will just goto Sprite editor skinning a litter on will select the school. Announced the lieutenant This you can see that we have some problems. The fix This will select raid brush on we select this poor on will paint on this world. This is well done. Well, despite on people on, then we can paint only worthless is ill increases the hardness. Now, if we were to preview clothes and rotate this bone you can see that it's so I'm going fixed other than this part of the scribes so again will go the way brush on We'll paint it over here now. When we wrote it, it works Possibly Now we just need to pick up like on We can see the ethical here After some time I need the right hand will be with you on the left timeto before So I need to write Like to be able here on left like Toby over here. So now when we play, you can see that the player is animating right? This is how the anime player inside unity initially all sayings the left hand rotation so It may be a while here. Um, at this time I warned the left hand to me. You're here on finally, Would there? Yeah. We want the left on Tokyo here. These right hand of your hill. Right leg to be your fuel left leg over here on after some time. We need the left leg over here. Right leg with you. The right hand or here on left on over here after some time. So at this moment, we want left hand to be able here after some time. Any it to be alone here on the right hand solutions. Miller here. Left leg on the right. Finally left hand. So now when we hit play, you can see that the glories and meeting at this moment, we can rotate the left hand on the right hand. Yes, I think this is fine. You can just play around with this on Make your player animation awesome. If you want to increase or decrease the animation speed, just select Leo on the animator. Go to window animation on Animated over here. Just select Leah. Walk on. You can say this pain. I'll hit me. And then I laughed at the speed so that I can see the animation speed. So I said the speed 2.1 may need more 0.6 17 I'm 70.6. So it has been problem 60. By going to a window, I'm a nation. If the animation needs to be smooth, the final pose on initial polls must be seen. So I'll tell like this and do it. I said at this points copy. Basic. Over here. So now it's working. Perfect on smooth now, seriously, we can see the small admission if you need. You can even admit the body. I hit record button on uh, this particular point. I will get it forward on this particular point. I ordered it back. Dill it. This could be the end points on. Basically, if you need, you can even anime the head over here, then create a new folder will call her script. We'll create a new folder. We'll call it. That's on. Then we'll write and draw. Player inside here will diligently Thanks for watching 5. Creating a scrolling background: Hey, game developers Shankill from San Sets. In this video, we'll create a sprawling background for RG in the assets, right? Like great and human to you. I'll call it DG over here. Select shadow toe. Unlike texture on here, select the texture as a base runner. Are VG now in the high lucky right pick created required. I'll resize it so that it fits the screen. Now drag and drop the material over required. Now you see that the object has the image saying that off this bathroom now in the B G material. If the change offset, you noticed that the image will scroll right, but it is not scrolling in a perfect manner when this object or this part of the sprite leaves the screen, it must enter from this side. But it's not happening. Right fits this. We just need to go to the right and so wrapped more from clamp to repeat so that the sprite repeats itself when we change the officer. So now when we change the offset, you see that the sprite is repeating on it is not being wrapped support. I'll set back the offset to zero. Now we need to achieve this through cold. So therefore I was stripped to your clad. I'll call it Scroll first. I really quite to be g on. Then I open the split in order to change the offsets of script. First, we need a reference for the render attached to the game object. Therefore, first we could've render in Crete and render I'll call it, then on in start function. Also then equals get competent render. So watch just us every time when we played a king or when we hit the play button the vendor attached toe, this busy object will be as lying toe rent variable. It's not that always the render attached to the BT will be assigned to the rent variable The rendering attached to the object which you have that that's the script will be assigned to defend bidding. But now we go, Do you render After that, we need to access the offset on change its value. So here we go d rendering. Next we can get the material on. Then change the offset for that al Sadr in dark material that offsets the main texture off it. So if I holler over fortify our all right So if I hover over it, it says the texture offset off the mains texture. So this is the offset which is over here. Officer is a vector, too, right? It's because it has two values X and y. So therefore, I c equals new rector to on over here. I only need to change the exception, not the y offset. So therefore I'll pass zero as the Y value on over here I put a public slopes. I'll call it Scroll Speed on. They were here and say Scrawl speed on. I'll multiply it with dying, not tie time That time, because I need to gradually increased describes speed are I need to gradually increase the offset value. If I just say speed or if I just the scroll speed every time the X value of the upset will be set. Same as discussed me. If the school's been in spite, it will be said to find on over here. Nothing happens. We need to scroll. Therefore, minuto includes doffs that value Rajan for that, we need to multiply it. Which time, Doc trying. I'll say this handed back community. I said this close. Speak us one on. Now for hit play, you should notice that the Bagram scrolling on Yes, it is. If you enter negative values over here, the background scrolls in the opposite direction. It's your English. Is it strolling? Spring increases. We can even enter float values. I mean decimal values. As I have declared it as flute, I can't even into a 0.1 going to 0.777 our soul. Now I'll just said It'll going three. Yeah, I'll send it. 2.3 will drag and drop the school slip inside the scripts folder. In this way, you can create a schooling background. There's another method operating a school in background. If your player is moving, you need to just in Stan. She ate sprites on. Place it over here, then delete this price, which are behind the player and again Unit doing stand. She s brides really described, which is behind. But this process continues for this game, as the players position is fixed, will not be in stance creating this price and letting them, by this matter, you can produce call in Bagram. If you want to increase the by value gradually, you can just go back to the script on, then pass zero as the X value on stroll speed multiplied the sine dots time, as do I. Well, I'll just typically Anya, its sprawling on its Why values gradually increasing if you had a negative sign, the direction voices. If you want to throw the background and both the access in the X as well as why access? Just go over here past X value as strong speed into time that time as well. If you want to have a different straw speed for the X axis and why access just great to labels saying Strong spirit X on school speed white If you want to scroll the background with same values, the extent why access pass the same variable into time guard at the time. If you want different speed for why on forex Great two way tables and pass them over here didn't reset the offset. I'll end the describes but access 0.3 on why that's 0.1. From now, the background must call in both X and Y axes on it is yeah, the convergent urinating number direction reverses in this game. Only want to stroll in X axis should be. Do you think you guessed it. We only want one variable on, then passed zero as y value. That's it. Back scroll. Speeders 00.3 on seeing the scene. Well, just resize required so that it fits the stream. Yeah, Now is there to see I have saved us sample scene. Yeah, that is about these rolling background. Thanks for watching. 6. Setting up Player Controller: Hey, game developers Susanka from San Socks and this video will crit air controller for RG. Now we'll open pre Fabs folder and drag and drop the player here. We had the player, but we can't seat for this. You just need to change the position off, Required said. It was zero. Now you can see the player. It was because quad washing friends off nuclear. If it seemed the friends off the player, we can see the player so will change its to see position to zero on. Make it behind the play. I'll switch back to to remove. Yeah, now we have a player When we hit play player just animates solid. No, when we take, we need a player to jump over here on. When we were talking, we need to play to jump back over here. For that, we need to create a script before that. Al Mahdi player to center. All right, I want to play over here. You move the player wherever you want now had a script for Chechnya. I'll call it player, then brag and rugby players with inside scripts folder land open the script. So first as we the public legal on. Call it input. So when we get back to unity, we can select a list off buttons or keys to set for the input variable. So now yeah, we're here. You can select the key that you need so that when we pressed the key play gyms, I'll just select models. Zero miles zero is the left mouse button on. Go back to the script on in the update function I took. If, as they input, don't get so, there are three functions to get input from the keys. The 1st 1 is get key. This function returns true, while we are holding the specified key part. That's the argument, if we have specified, or if we are past s key as your argument, it keeps on returning true until we release the button. Which means while the hold, the key which has been passed us the argument. This function returns true while get kid down returns true when we move the button, which has been passed as the arguments down, which is nothing but thick getting up, Britain's true. When we released the button past nasty argument, I'll say get kid down as I want to Moody player when a player clicks the input button on, I'll pass input as the argument inside this I'll say debug dot log With just Prince pestering, I'll say, Click. So now whenever we click the input one, which is nothing but Mao zero button picked message should be displayed in the concept. I'll just enable the messages. And yeah, when I kicked the left mouse button click message should be displayed. I'll just moody council over here. I'm going to click now. Yeah, The message has been displayed for breast again. My sons will be printed one more time. As you can see, it has been printed two times by clicking entry for five and so on. I can even change the key. I can start it toe any keep it is available over here as I do the backspace on. No. If I hit backspace, take message should be display. And yeah, it's dys plane. Now when you click the button, we need two more deeply over here for that island and rigid body jewelry on a box collider . I'll just click Edit Collider on and more to the player place. Yeah, I think this is perfect. Now when he play. You see that the player will fall down. It's because of the rigid body competent. Yeah, I saw that. It's because physics is are playing gravity on this body. In order to stop that, either we just get said gravity scale 20 r radical lighter over here so that it stands on it. Now, I am not going to set gravity scale to zero. Instead, I ladder collided over here. So for that all right click created through the sprite on a select this bright as as the U . S. Bright ill said It's ordering layer to fool so that it's on top of everything asserted Z value to zero on. Then I'll increase its size. I just said his pride at Space Runner so that you can see it. I would agree that size. Yes. Well, he'll be hot. You already have. Ah, black swarm this grading. If we drag and drop it over here, it looks quite well but we need to Attica lighter. What can be done? We should just done off this pride. Render on then. Well at the box Collider. Totally now You should have. Nicoletta is same as the ship off the stripes. We needed to be transparent. So therefore I'll disabled Sprite turned over. Now when I hit play player will stand on this platform or on this right So that he standing on this platform. Yes, it's actually not morning, so I used the world standing. If they see this window, it's actually moving. It's because of the tricks that we used for the sprawling Bagram on the player I rename this to platform. I'll create a new game object, I'll call it and we've moments all research position. I'll rather the platform on Bt inside off this environment. Prepa mo When I take the button that I have specified over here, the players would jump over here. What can be done? I'll just show you. You just need Toe said Gravity scale to minus one. You started place moving up on this morning extremely upto in finite distance. We don't need that. We want a player to stop over here. So do you know what we can do? We just need to add a collider over here. How can we do that by the same matter that we did for this particular platform, instead of repeating the whole steps just duplicate this by pressing control. Be on Windows or Command V. If you're on Mac on, just drag and drop it over here so that when we take, the player will not move outside off the screen. So now if I change the gravity skin to minus one or any negative values, playable more up on the stops over here so that if I said it a positive value, he comes now, it can be any value. If it's greater, he'll move faster. If it's less value, Player will move floor, depending on the value that you are entering on, Grab the skin. If I said it'll minus seven, he most much faster so that if I said the dough then or 30 it will be much faster. So by using grabbed the scale we can multiplayer up on down. So in order to change the gravity scale during runtime or while play first, we need a reference for the rigid body. Therefore, is a rigid body. Torrey. I'll call it RB on in the start method as they are, we equals get competent, rigid body. Julie, I think you know what does the US I had explained this in my previous with you on over here , I'm not going to display anything, so I just convertido dough a comment or you can just remove it off When I take the button that I have specified. I need to change the Raptors skill value. Therefore sexually RB, which means I'm getting the rigid body. Then I need to get the gravity skin. Therefore, I'll say dot rowdy scale. This is a float value as we can also enter decimal values over here. Al Qaeda public. I looked up and celebration on the public float down and celebration. Whenever I take the specified button, I'll said the grab the skin to up acceleration value. I'll head back to unity. L said the up acceleration value to minus side. You can set it to any negative value. Negative because we need to move up so that the grab the skin must be negative. I'll sit down acceleration toe fight Obviously Now, when I hit the in good button which is the mouse button grabby scale will be set to minus five. Yeah, I saw that, but when I think again, gravity scale will not be set to five. I have not called at that part yet. Now we'll do that. When will we know that we need to set gravity skin toe minus phi on when we need to settle side? We need to think about this one days. You can add scripts to the platforms on, then create a residents off the script on. Then you can play the two variables over here off bullion type. When players this particular collider, you can sit collided up variable Astro collided down variable last fall's on when players hit this collider down. One collided down equals true and collided up equals falls on then by talking that you can change the gravity scale. But the easiest method would be creating a boolean variable. I'll call it direction. Initially, it will be false. If you want. I can just sell it false so direction will be falls. It's better to say more when we take the button will talk if more is true. Instead of this, we can just see it more. The things inside the block will be executed. If this is true, I can just say this is equal to equal to true are I can just passed the 1,000,000,000 variable If this is true, it will enter the if block s, which means more peace falls as it our bid or grab. The skill equals down acceleration. After setting the gravity scale, we need to change the more variable value. So when your piss true will say more equals false on when more this walls will say more equals true So what we're doing here when we click the button initially more will be force . It means things inside This will not be executed but things inside else function will be executed. So when more peace falls this said these things will be executed first will set more true because we're moving the player upwards on. We're changing the acceleration force. We're setting more true because when we kick again, we need to move the player up As we're moving the player down over here. Over here I'm changing the Gladys Kato down acceleration, which means I'm going the player down. Next when we click the button next one with the input button, more will be true. As we have said it to truth over here, the things inside this block will be executed. So first it will be set the falls, which means when we click again, we need to move a player down on, therefore, as more well before things inside else. Block will be executed after setting Lito False. I'm just changing. We grab this came toe up acceleration as initially. I need to move the player upwards. I'll set more equals. True, That's it. This dust the job. I'll hit play. I'll press the left mouse button. You see that the player goes up on when I press again, he comes down. It's looking perfect. But when we take the left mouse button and when the player most up the plan is toe rotate, so that is, let's will be on the ceiling. How can we achieve that? After changing the gravity scale value? We need to just rotate the player now. Oh, can be loaded a player when player most over here on or here, if it's was a regular Sprite, so I'll just really Sprite. I'll select us right at a press esto focus. I'll tended to look like so this waas a single sprite. I just need to enable and disable people I value through cool, but this player is not off single sprites. It has multiple sprites in it on. I need to change flip by value off every sprite for findable it. You see that all the sprites gets flipped, but it's not working. Fine. Go to fix this problem as the Flip Kumpulan method will not work in this bright, we can just rotate the player notice if I rotated on the easy access. Not only its rotation is changing. Its position is also changing. I saw that first, I need to rotate a player on the Z axis on, then on the Y axis. So why should be minus 1 80? So, yeah, In this way we can rotate the player. We could have just changed the rotation, but you notice that when we rotate the player, not only the rotation value changes, its position will also change. So now, as we don't have single Sprite to enable and disable flip, why competent? I'll just rename this to clear tipos up. I'll duplicate it. I'll move to the exact scene place on. Then I'll change tradition. Zero addition to 80 on Dwight oration to minus 1 18 so that it looks too right. I just know it over here I'll just rename this two player Teeples down, and now I can just enable and disable this plight that I need. First, I'll only enable player people's up. I'll go back to the script so to enable and disable this to get more picks first. I need a recess for it. As a public given object, I'll call it player up on a public king object. I'll call it player down. So when players went up, what you need to do is when it was set laid down game object to force, which means you're setting it to force aan den enable flare up game object by saying God said, acting true, we're just enabling it on when player is going down. We need a such player down. No true, clear down to true. So this game object is player down. It's not up as the players standing on the ground off course. This name can be anything, but it makes sense if it's player, people's down on this must be player. People's up. So when the player is moving up, we need to the activate the player down prefab. They will say they're down the seductive falls. It just does this job, it just disables the game object on Then I need to enable player up. So therefore I'll see Let up said Active. True So it just enables in this manner when players moving down I understand they're up, so falls. I need to deactivate it, play up. So there was a player of dark, seductive force. So it's death. This job and then clear down Got set after truth with just enables like this. Now we'll select clear on Dragon drop player up I don't see ago now everything must book perfectly on It was so the mechanic is working perfect but deeply is not animated. Let's fix this toe Fix this When bility player, we ran Andrabi player again Well, my door here Have you seen place? Very cool Idol is there. I'll call the spare down I'll duplicate this. I'll call this player up so they're up Must abs a rotational 1 80 on Dwight rotation as minus 1 80 All this movie object over here Anil disable it now a dragon drop player down on beer And now even the animation will work Perfect. I saw that when we click this game object will be set active on this. Enacted on a tick again, this will be said active on this inactive SAPO. Now we're done with the player moment. Thanks for watching. 7. Lets spawn obstacles !: Hey, game developers Shankill from San Socks and this video will could spawn Manager, which sports off Stickles at the end off the screen. So for that list with a new game object, I'll call it's born manager. I just change this to orange sheep so that it can be seen in the scene on I just drag and drop it over here. I researched its position. I learned a new script. It I'll call Scorned Man's Wrestle Dragon Robert Inside Scripts folder on I'll open it up over here. I need to sport objects at this point this point on this point. Therefore, credit three empty game optics. I will bonus Over here. I was living in this 2.1 on I'll Change this toe red circle on Duplicated sh moved over here. The picket again. 11 model. You. I go to the middle on this. I would rename this 2.2 on. This is 2.3. I'll create a new object. I'll call it points on drag and drop all the sports inside spawned Manager first winning the reference for those phones before it's a public transform, it will be Ofari. I'll call it points are spawned points. Next, I need the objects that I need to score there. So the objects are space Runner are 798 I to therefore For that, I'll said Public game object. I'll call it Objects to Spong, then include a public loot. I'll call it time the pain spawn on a float. Current time. I'll said this to zero in the update method as a if current time. Is this a then record too? Zero? I will call this bone sanction, which sponsors the object so I could've wife's form on then. As a current time equals time, that means born as I see current time, my Sequels time that time in this born matter, I said, People don't lock bombs as as a current time minus equals time dot That's a time in this born matter, I'll say people that look spawned. So what these lines off court does, It's time betweens bonus to for every two seconds spawned, matter will be called on object will respond initially, kind of them will be set to zero, so therefore current time will be equal to zero on their force were spawning the object in this point function on, then I'm saying current time equals time with means. Born noted. Enter the update matter again Now Current time is not equal to zero or it's not less than zero right as we have said it toe time between sports now it will enter the else block. It will decrease current time which time? Daughter at the time value so that after two seconds this will be set to zero on even it will be less than zero. As I said after two seconds, this current value will be zero or less than zero. When it enters the update function again, current time is less diabolical. 20 Therefore, we're calling this pond function on. We are setting current timeto time between spawned this process repeats if you want limited amount off objects Toby spawning a particular level Greater public float. Call it objects to spawn on then over here that if objects the spawn is traded on zero on enclose it within the slow brackets. I already have a variable called objectives Born The oil called this number of objects to sport on whenever you're spawning it just decrease its value. So now when number off objects is said to five or a number of objections said to to who's rated an zero. It will wait for the amount off seconds that you have specified over here time it means gone on. Then it will call this pond sanction off that that amount of time on then were depressingly number off objects to spawn, as were spawning the object. So it will be one. After two seconds, it will be called again. It will be zero. We have support to optics. Number of objects was born will be set to zero. This is nothing but a number of objects respond minus equals one with the same US number of objects equals number of objects minus one. So instead off writing this line, of course, all this line. Of course, we can just write this line off, but this is post increment. First, it will written the value. Then decrease it. If you do minus minus, number of objects respond. It will be called us predicament. It's means first it will decrease the value on then return it. Boat will work at this moment. Now let's say this on head back to unity. I said time It means going to to number of objects to form toe to as well. So now only to object must be scorned for every two seconds. So Sporn message has been printed on after two seconds. It has been pretty again, but it's not bending anymore because number of objects respond is set to zero notice again . After two seconds, number of objects to spawn value will decrease 12 So that and now it owns point animals because number of objects to spawn is not great than zero. If you want in, find that number off Texas born in your level. Just remove this variable on this collision. Even this line off court. That's it. Now, if you want limited amount of objects, Toby spawning your level just to use this technique on alleles block here, which says it they have spawned all the objects are if number of objects is less than or equal to zero, just enable Level one panel just create a game object. Call it. One panel assigned in The Inspector on Dell's block, Say Wonder said, Active. True, that's it. But I need this form, infinite amount of optics. Therefore, as all these things Andi Inspiron function I am responding. Object. I'll convert this into a comment. In order to sporting object, we need to use a function called in Stan Sheet. So it's in Stan Sheet. It will take three arguments. The 1st 1 is the object that we need to spawn. It will be objects to spawn. I need to spawn a random object. Therefore random That range on this takes two arguments. The mean value on the Maxwell. The main valuable zero max value will be objects to spawn God lands. Next. It will take the position that we need to spawn the object. That will be a random point Among this point ones, therefore, is this corn points off random that range zero comma spoon points that land on. Then we need to pass the rotation. I say that squad in in not identity because I want no rotation. It just sets the object rotation 200 and zoo over here. Were you to pass the position? This spawned points variable is off transformed later here. If we need to pass the position really to just say transplant that position cool. So now a random object will respond at a random point with no rotation every two seconds. If time but Means Born is to second. This time, Bettman's glowing can be anything. So I need to explain what this line of code us instance created the function, which sponsors a game upset. So it takes three arguments in this case. The 1st 1 is the game object that we need to spawn the game object that win it just want is not one. Therefore, I used as a as its honorary trying to pass on index. I'm passing a random number between zero on objects to Sporn dot length so that a number between zero on object to spawn length will be returned random. It can be one toe or anything between zero on this island. Then it takes the position where we need to spawn your object, reassuring the position in spawn points variable. Therefore, biceps one points off as its and other I need to pass an index. It will be a random number. Before I said random, the train with mean zero on its left guard position because we need to pass position, not the transform on. Then the rotation. It would be quite a me and got identity as I know. No rotation. It will be said 200 and zero. Now drag and drop this bone points and your dicks to school. Go to space from art drag and drop space when our to Space Runner Art nine Space Runner are 10 8 on finally seven select All these said it size 2.3 as the mutilated collisions as we need to reduce player health. When obstacles collide with it, we need to add a collider for it as it doesn't have a particular shape like square circles . I led a particle collider duty so that the collider will be as the same shape as that off the sprite. Now go to play, perhaps folder. I'll rename this to Space Rock This too bonus too. So this is Mourners to this will be bonus one. This will be based satellite. Finally, I think this is some broken parts for our brain image. The broken part. Then dragon drop all this inside pre fabs folder Now did it? All these selects born manager Rod and rob the pre fabs into objects to scorn born other Yeah. Now, as the time between is going to three so for every three seconds, random object will responded. Random spawn point. Yeah, one has been scorned over here, the other at the same position. Yeah, the other it here, the other here. Obviously, it will not mean, as they have not added any script good. But whenever the objects get spawn, it's not visible on the screen. It's because it's the values minus 21 on the when the ordering layer is zero. We need to change it so that it will be visible on this game scene. I select all the obstacles answered, ordering later fight so that it will be on top of everything else as an export. Points. I said it Z value to zero so that it's on top of the quad. Now the objects will be visible to us. Yeah, he's was there to see. Thanks for watching 8. Obstacle Mover: Hey, game developers. So Hsiang Chiao from Sand starts in this video will add a script to the obstacle so that it will move when it has been spawned. So I'll select the obstacles allowed a stripped it. I'll call it Move first, let's smooth Inside Scripts folder and then we'll open it if this is the object which has been spawned. Oh, here we need to mort left side so that it reaches deeply or it reaches the other end off the screen. First Al Qaeda public load alcohols. More speed Where there are various methods for moving the object over here alludes, transform, got translate metal, which takes a single argument. But it's awful factor tree types as we need to move the object wells left, which means we need to change its X value. In this case, it's decreasing. I need to say, recto dot right, if we want to move in this way, if we want in this way, we need to just add a negative sign over here. Or we can just change this director toe got left. If we are not adding a negative sign on, then I'll multiply it with small speed. I'll multiply it with time dot delta time as I need to move the objects according to the time, not different at back to unity. On Enter the most speed, I'll delete the one in the hierarchy. I'll select all the obstacles on, Guy said mostly to 5.35 point three. Because if the object moves with the speed, it looks as if the object is moving with the background. You can just experiment the value so that the obstacles will move along with the background . Everything is working perfect. But when the object moves away from this side of the stream, we need to destroy for that will wear the collider at the end off the screen. I can just duplicate this on change its sights. Yeah, I'll call this destroyer on. I let us slip through it. I'll call a destroyer as well. Let's open it up. So then we need to destroy objects when objects are at this end, off the screen on when it collides, when the object collides with the destroyer, which is this game object, really, to destroy the objects that collide with this. So in order to detect collision, we need to write a in malfunction void on collision. Enter Tory so it will. It will take single argument. This is the information off the object that collides with this particular object forward Script has been attacked here. Will Chuck. If collision which is this variable? It can be anything. It is the information off the object which has been collided with the destroyer. If this is the object which collides with the destroyer, this object will be assigned to collision. Al took if collision dot game object got compared. Tag obstacle. So I'm talking. If they collided, Object has a tad called obstacle oil Select all the obstacles allowed a new tack for it. It will be obstacle on. I'll select them all. And as an obstacle tack boot. I'm checking it. The collided object has attacked called obstacles. What I need to do is I need to destroy that particular object I would say destroy the collided object. That's it. Now, whenever the objects collide with the destroyer, they get destroyed. Let's see you see there. The objects are not being destroyed because in two or three games to register collision anyone off the object must have rigid body. So I'll add rigid body to re ill said. Grab it. It scared to zero because I don't want it to experience gravity and fall down. I phrase it position on as the last rotation. Now obstacles must be destroyed when it hits the destroyer on. Yes, they are destroying even place colliding with the destroyer. But why isn't he destroyed? It's because Player doesn't have a tackle obstacle. But all the obstacles have attack called obstacles. It's because we are talking. If the game object has a tackled obstacle and only destroyed, it collided. Object. If not, we're not performing anything. You also noticed that when obstacles collide with the player, player will rotate on, even knew. But we want the player to be fixed at this particular point on, not even rotate. So we'll presents rotation on exposition because when we take here will move up and down. Therefore, we should not phrase y position. I saw that the place not being rotated on, not even move. We'll just move the destroyer over here. We'll move this point quite up. You on this one. Sanusi Times were watching 9. Collisions: Hey, game developers Suzanne from San Saw in this video will detect collision on Add points to the player when he collides with the bonus game up. Before that, let's move. Destroy a script inside Scripts folder on. Then we'll open. Play a script to detect collision. We need to write a function. Woods is stopped. It's on collision. Enter to be, we have to use dysfunction when East Trigger is not enabled on the game. Object. If East triggers enabled, we need toe type on trigger. Enter story collider. Totally so here outside, if they collided. Object dot game object. Saudi object collided dot layer. If it's equal toe so less recently, years 1st 1 will be obstacle. 2nd 1 will be bonus, so we'll check if the collided object has layer ate. What we can do is either Nicholas player Points are destroyed. A player on finished digging. First, I'll decorously point the four Republican points variable. It will be zero initially. Andi, when player collides with the object, which has layer eight, I'll say points minus miners with the same ass points equals points minus one. After decreasing the points, I'll destroy they collide, adopted else if I took it. The collided object has layer off nine, which is called bonus. I'll increase the points by one on all this radical adopted. That's it. If you want to destroy the player when obstacle collide with them, just said this try game object. This will just destroy the game. Object for rich. The script has been attacked here. Play script has been at us to player itself so player will be destroyed. I don't need to destroy player. I just need toe decrease the points. If 0.0 Andi obstacle collides with the player, we are decreasing it. Therefore it may become negative. I don't want negative points like minus one minus suit in my being. The file check if going since great than zero Generally I'm because in points value now let's go ahead on add layers for obstacle So everything will have obstacle layer except bonus came objects. I'll sell it to bonus No. Whenever player collides with obstacles, it must be destroyed on points must be decreased whenever it collides with bonus three. Perhaps like this points most increase And yes, it is inclusive on now it's ridiculous. Notice you It has decreased on even there get destroyed when it treats is the destroyer game of it. Now when the 0.0 on, If I collide with the obstacles, it doesn't become negative. It's because I said decrease the points only if it's great. Land zero You feel one points to be negative. Just remove this condition when player collides with bonus one I need to increase play a point by one. But when plate collides with bones to I need to include us player points by something else . So now what I can do is I can just do it another Leo. So I'll call this bonus one. This will be born us too. On this lady with a bonus one it's late will be bonus to over here. I'll say s if collision Dargan object. Dr Leo is equal to 10. Bonus to clear is then you can see the number over here. What l o is I'll increase your points by two. This is same ass points equals points. Bless too on then I need to destroy the collided object as I need to destroy the objects which collide with the player. I'll just remove this line on bested at the border I limit over here. So now first it all dusty points based on the condition. Then it destroys Dick Alighted object. If the collided object this obstacle, I'm recusing the points. If it's bonus one, I'm including the point by one if its bones to I'm including the points by to on Then I'm destroying the collided object. Let's start this out Now you see that the player will fall down. It's because we're destroying the collider which is available at the border. So this one, whenever dis collected a player, we're destroying it, right? We must only destroy if if the object collided, it doesn't have a layer off zero. So all the sprites have earlier of zero except the obstacles you can do this are you can't just cut this line off court on based it three times now it must work. Perfect. So now it's will increase by one. Now it's become zero on. Now I'm just waiting for the bonus to off sickle. Okay, It's not being spawned. What I can do is I can just drag and drop in the sea now. It has become three. Now it should be five. It is. So I'll do anything. When player 0.0 on Difficult like to the obstacle, I'll just destroy the player. So I said as destroy game object here on Turkey If the collided object has eight layer on I'm talking points is greater than zero on reusing the points. If it's equal to zero less than zero. I'm just destroying the player now. When I collided with the object with 10 the player will be destroyed, but the objects will be spawning to fix this. Let's just open draw script on Spawn Man is the script, as if game object dot find game object with back Leo is equal to know which means the player has died. I'll say ridden men Player has died. We should not put from all these things and so on the object. Therefore, we should say Ritter, even in the scroll script What we can go IHS copper fees. Same lines off. Now let's select Leo on a same clear that would, as we are finding the game object which has it that called Leo on now on now they must be destroyed. Everything must look like they have been posed on. Yes, The Babylon is not scrolling on The obstacles are not spawning. If you don't need to do this, just go back to the play a script on when you're destroying the player. You just make sure you have set time. The times gain equals zero. What this does is it just boss digging on just gone with this intercom int He went over hell Thunder timescale equals zero Just boss Begin Therefore, when we study game again, we need to resume beginning Therefore was the time that time skin equals one And even now everything must be post when polio paralyzed for the obstacles with zero points on Yeah, the game has bean post Now we'll just display the points at the top for that will rightly create you I next so a select foreign style Too bold foreign size to 15 on I ride it to the top I said It's color to any black I said it's size to 20 I'll rename this two points Next on really to set the value off points variable Do this text right? So first we need a reference for that text Use you eyes. We need to import a class called unity engine. Don't you I on Then I quit a public fixed. I'll call it coins Next on in the Apne function, say points text. So first and we have the reference off the text. We need toe access. The text which is over here before it's appoints text doctor next equals points This source an error Over here. It's because points is off in type and he'll be Nieto pastoring the text. What we can do is convert this end to string by saying dot will stream. That's it. Now we can drag and drop the points text three points, text variable and the play a script. So in just drag and drop it. So, yeah, we're here. You can see player points. I'm just waiting for the bonus. Yeah, so wise is being increased on. When I call it the obstacle, it gets decreased. But I only do not need indeed it over here. I want to say the player. What's that? So for that, I'll include a pre six over here, I'll say points less. Big points for in string will be displayed first on, then the points off the player. Cool. Now let's say the scene. Thanks for watching 10. Setting up UI's: Hey give developers So Hsiang Chiao from Samsung's in this video will create us stuffs for RG. So now whenever player die, we need to Saudi Die panel. Therefore alright, it I'll treat you. I panel I rename this to die panel. You can choose the color over here, so let it be great says on you can choose the transparency. I'll just ragged. I panicked at the top so that once text will be displayed on top of dependent here as well The you I've button. I reset the image because this looks cool than the default Spite. I'll bring in this too replay on even the fixed, a xylophone style toe. Bold. I'll duplicate this. I rename this to Main menu. Yes, we'll be creating this later. Now let's disable this body canvas will 11 loader script so that whenever we take the buttons, we need to load the Elevens. Let's move this inside Scripts folder on Let's Open It up. Oh, here First, let's create a public game. Object will call it loading screen so that whenever we load, any scene will enable that loading screen over here. Al Qaeda public void. I'll call it low level on. It will take string as the argument. I'll call it level Name? Andi. I'll be calling this function whenever we take the button. So whenever we click the button, I'm call dysfunction. I need to load the level that has the name. Same as that. Off the argument which has been passed. So we should use a class using unity engine dot Seen management. So we're here. We should say scene manager Dark Lord. See on here we will pass the level name. So before lorry will enable the loading screen Lord Extreme not set active truth. We'll go back to unity. I'll select the died panel. Now let's rape the loading screen. I heard you. I panel let this be off Red color a lot of text to it. I'll call it loading, so I display it over here. Its size will be 20 on size board on its color will be read. I've been in this to loading panel on Disable it in the can Marcel Dragon robe billowing panel on. When we take the replay button, I need to load the level. Therefore, I'll call the lower level function on the level makes a Whenever we take the replay button when to load this particular scene, so the same name is sample See so ago sample seen on Whenever I think the main menu button I need to load main menu See which will be creating later. So it's name will be made men when we need to enable the Diet panel off course when player dies. So in the play a script first we'll take the reference off the dive panel on before destroying the player. What we need to do is enable the Dye panel therefore also that panels are said, acting through as we're not accessing points in other scripts, we can't just removed public access. Specify Andi. Even as we're not setting points in the inspector's we can remove here, let's rock and roll the die panel. Let's save seen on gets added to the bill settings Just rag and drop your seen to rebuild settings in order to lure any particular scene. That scene must be in the bill settings to Lord that Now let's save seen on hit play to check whether this book Andrea, this working let me take the replay button and yeah, the scene has bean restarted now let's rate main menu. What that will create a new scene. I'll clear the your image. Andi al. Choose Space Runner R B G on scaling solid. It fits the stream size Elden in this to be G on. I said You, I scale more toe kill with screen size so that I need to scale the images based on the screen size. I re skills again. Yeah, now. So we just decorate the main menu by adding the player on all the right. Just running up all this Brides select canvas on, said Renda. Moto screens base camera on Dragon. Drop your camera so that all the sprites are visible. Andi, I'll just increase this bride size so that I can see this rights correctly. So this is the head of the player on. Just know it. Over here on the next one is the body. Finally, the 3rd 1 is the leg. The food one is another leg. The cyst one is the hand. The 61 it's under the hand on. That's it, I said, bodies ordering layer to one sorted. It's turned up off the left hand. I dislocated like this on the mood of here I set other hands ordered in late one solid. It's on top off the body. I'll rotated in this manner on Place it over here. I'll select one of the legs said it's or in later one on. Yeah, this is fine After the new game. Object, This will be Cleo. I resent Exposition on Dragon. Drop the sprites inside layer. These sprites are the posts off the player. I really was its size 2.8. This will be the obstacles. Credit New object. I'll call it obstacles. And then I ran into a pole this inside the game off Either use it size 2.7. I mean with a space rock with you. The base people were here. Bonus one over here on a stool over you Finally, the broken part of you. Now let's great buttons. So let's go to you. I button on its below. These prides. What we can do is we can create another canvas. You can call it button canvas on the selector Enomoto screen Space camera black and drop the camera on over here we can pretty body were set. Are the layoff list to seven started? It's on top of everything else on. I'll call this play button. I'll rename the text to really and I don't want described. Therefore, disable it. I am a little here. I'll changes color to white foreign style. Pulled on size, too. 25. I can increase its size so that when it was placed, that light has been breast. We'll load the game now. We'll trade the loading panel, as were credited earlier. Solis, Right? Take you, I panel. I'll call this loading battle. It's off red color. I got a text to it. I'll call lording Will be off red color form size 25 4 style boot. Yeah, you can just disable this level orderto but in canvas drag and drop the loading panel. Whenever we click the play button, we need to load the game. Therefore I'll enter sample scene as it waas the same name. Yeah, let's see. I say the scene as men. When you go, you know that load, this main menu. We need to add it to rebuild settings as they need toe load Main menu first with drag it to the top. So the scene at top most will be loaded and someone opens your game, they said. Orderly off other hand, toe to on will hit place. So now when I hit play game scene has been loaded on. When I made menu, main menu will billowed, but when I maximized again, you see that the play button is somewhere else. Instead, off. The obstacle has sprites. We can convert it into a button so over here will enable the image. Tuesday US pride as spaceman right will deal it. The space satellite on this will be for here on. We'll make this as a quit button, though Name is Space Runner are to delete it, duplicate the play button to bring it over here. Sell agreements as baserunner are, too. I'll rename this to quit button on even the text. When I press squid button, I need toe quit dicking they've while Adam slept it. I'll call it quit. I'll open it up. So over here, Al Qaeda Public Voice, I'll call the function Name is good game on. When we press this button on dysfunction has been called. I close the application by saying application the quit. So whenever I get the quit button, I need to call quit game function so a pretty place button drag and drop the object with as they script on, I'll call the good game function. I'll say the seeing. If you want the help button, you can create it. Go in order to do that. Just duplicate one of the button it over here said, Like the sprites really in the button. Even the next, you need to move this buttons at the top so that when you enable the loading panel, all these buttons are below the loading plan and we cannot click the buttons when level salary just deal. It's question are 10 have created help button. So whenever I press the help button, I need to enable another panel. I'll call this help panel on. I'll choose despite as a base runner. Ryuji, I'll increase the value told it's not transparent, Andi, I text increase the size phone styled, bold foreign sides to 13. Hello to anything with your life here, I say health. It's a left click change layer position. This will be controls on, I say about the king. Collide with bonus objects on not obstacles to gain points now is great. A button inside This will be back button so I would drag it over here. I'll call this back as a phone start. Bull size to Andy Color to blue as a text color to gray on button color to whenever we get this. Pardon. Need to disable Help panel. So on. Click. I need to disable the health panel. When I take the help button, I need to enable the help panel the so I'll enable this option. I need the back button. The right bottom off the screens. Therefore else electors, I need the play button over here with button over here. Finally. Help button over here. That's it. Helps a accepts you. I skill more to scale with screen size on my work again, make sure interactive elicit true so that you need to interact with the buttons. So when I can't be helped button help panel will be displayed on buy kickback. This panel with British people quit only works when you build a game. So now it doesn't on Everything works fine in the game. We need toe line the points who will goto sample, see canvas And so like you, I scale more to skill with screen size on its position must be at the left does well here. So we'll service. See how it will be aligned properly. Should go. Thanks for watching. 11. Setting up Audio: Hey, game developers to San Kill from San sets in this video relaxing tombs for our game. So first it's open main menu. I learned a new object. I'll call it all you. For this, I'll add all your Seuss on. If you have a tune, just drag and drop it inside the Assets folder on then Dragon. Drop it inside audio clip. So now when you enable look on play on click the audio starts playing on. It will start looking theme because the audio is only available in the main menu on not this scene. Of course, we can add a audio source over here, but the tune starts playing from First. Let me show you I could. Empty object. I've had all your souls on a choose to I'll say the scene now When I moved from main menu to sample scene, the audio is start way. Need the audio to continue. Therefore, we'll ask Rip, I say. That's all you. Let's move it inside. Scripts folder on We'll open it up So first will create private static audio. I'll call it you D. So here I'm creating different subject of the class, so this name should be same as it off the class Name on you should include static key world in the big function awake the function which will be called before start function. We don't need update methods Over here. I'll check if God is equal to know what I do is as the old it was this on as a don't destroy on load this dot demote else Which means all yours Nautical Tono has say destroy remote. So what we're doing here here are created reference Object off the class or you so in the other function and talking if or is equal to Mel obviously here asked not assigning any value to the or valuable it will be cool to know if Yes, I'll said all put the strips on I'm saying Don't destroy this object when we load from one scene toe other see when were in Maine menu or will be equal to know we're setting articles this now it's not equal tonal on. Then we're saying Don't destroy this game. Object this game object When we move from one scene to the other on when you goto Theo gain . Obviously the only object in this scene will be over here because we're not destroying it. We're saying Don't destroy, Unload on. Whenever it comes back to the main menu, there will be two audio game optics, the one which will be in the scene on the other. With this morning from one scene to the other thing, you don't want to argue. Therefore, initially as it waas equal tunnel it waas set With this stripped now, it's not equal to know on. Whenever we come back to the scene with has audio hard will not be quota now. Therefore, be destroying the object with this available in that particular scene on, we're keeping the object. It was not being destroyed from the start off the game. Now we can set that out, Theo. - Now in the scene when player collides with the obstacle. If you want to play one type of audio and player hits bonus objects on one type of all European player hits, obstacles just duplicate this. Rename this to collect audio al drag and drop to tunes into the assets, namely hit and collect on. I'll drag and drop collect So the audio clip it really hit the audio clip. This audio is off, sir, Clint in the script. Just create public or your source. I'll call it Collects June on a public call. Your source hits you So over here When I collided with the off Stickles Ironically, it you when I collided with full subjects, absently collect you. That's it. Now let's drag and drop. Hey told you on Kala Tory. Now let's citizen the tunes. Yeah, you can hear that now Collect June is being played now Hit June replayed collect hit two different types off. Jansa being played. I'll go to scenes Main menu on Reduce the wall, You off the main or you, I would say to see hand sorting. 12. Setting up particle system and playing audio when player hit obstacles: Hey, game develop owes Shankill from San Sort. In this video will create particle system which will be scorned when player collides with something. Let's go to the game scene. Let's right click Create ethics particle system on here. You can see some particles now go to shape Selects shape from coun to circle. You see that? It's not actually circle right? But it is. You just need to change its rotation to zero now goto emission. Take the place button over here and do the count as 50 so that so many particles will be emitted out in this manner on decrease its duration to one. You can decrease the lifetimes so that it gets the strike quickly. I'll say this 0.3 I said the duration as point for I drag it over. Hell, I reduced the ship 2.5. Maybe going to Yes, this is fine. I'll Degrees they start like time on this size. You can, because the speed 2.1 our 0.3 said the start life in 2.5 lifetime to two on when you could play. You should see this kind off effect on just looking because we only want to play it. Once on, you see this kind off effect. I'll increase the speed to five so that I can see this effect. I said It's lifetime toe one. I'm just playing around with this value so that it looks cool. I'll increase the count. 200 or 200 said its lifetime 2000.3 in the world One. Yes, This looks perfect. I can set black time for 10 country on. I can increase the rate over time. I said it to 70. Yes, this looks fine. I change the color. Do some gray color. If you want some nice, you can add it. So yes, increase this trend. Live the frequency on. You can see some cool effort. Yes, this is school. Let's rename this to be hit up. It will move this over here so that when we play, it looks as if particle system waas played because of the hit. Let's set it sort of layer to seven so that it's on top of the player. Yeah, right. And drop it inside. Player. Now we'll open play a script. You We need a reference for the particle system to play. Therefore, as a public particle system. I'll call it Pierce on whenever player collides with something. What I'll do is I'll just play the political system by saying Pierce darkly. That's it. Now, whenever player hits something Hate Epic will replay. You don't forget to drag and drop it to be asked me about in the political system disabled play on our vic because we don't want toe plenty particle system when we picked up labor. So yeah, you can see the hit up it if you want to play some tune when player hits the obstacle, just create a game object called Audio at Audio. So stood on that and drop platoon that you want to play when player hits something on check Janovic because we don't want to play that on a Bic. I'll bring him this to tell you on in the script first. Really, the reference for it to play right? It was a public audio or your source. I'll call it here. So on. Whenever player hits something just played it all you by saying yes or don't play, That's it. So now we should hear to June's when player hits the obstacle, let me drag and drop the Vittorio servicing one audio is from the main menu. If I enter into the game seen from main menu to all you must be played This tune is off long land So he tunes must be off sort land so that it place on stops within few seconds so that it can be played again from the beginning. Thanks for watching. 13. Highscore Manager: Hey, game developers Sankyo Front, Sansa in this video will store the high school off the player on Displayed. So First will go to points. Text will duplicate. It's more it aside, this will be high school text. Let's open play a script. We also need a reference for the high school text because the public text high school on in the start matter I took, if not clear briefs dot Haski points al discreet one by saying clear brisk dot Seddon, the Kini. I'll call it points on the value and said it was zero. He'll get talking whether the system on which the game is running has point. Ski stood in it. If it doesn't have, which means the player is playing it for the first time ever, said the point. Ski 20 on the update mattered here will talk if they oppress DOT get into which is used to get the value off the key. I'll get points value I'll took. If it's equal to zero, I don't need to display anything because there's no high school made by the player. It's nautical zero as a high school text. Dark text equals high school, which is the perfect on the high school value. That's it before destroying the player when it struck. If the current points of the player is created, Bandy High School, what we should do is set high school. Dot text equals new high school on. We'll display the high school, which is nothing but the current school on. Then I under change the high school value because they play abroad, start certain the key on the value. That's it. You can just go back to unity on check this out. Initially, high school text will be empty. I'll just increase its size on Dragon. Drop it into high school next as Davis e. So now 0.0. No, it's one three way. We can actually compare the points because the player only Dyson points is less than or equal toe zero. If you are destroying the player instead, off reducing points an obstacle school, I'd You can use this technique. It only works if you're destroying the Clio when obstacles are collided without talking the point. So if you remove these lines off court on, base it outside Andi, you should remove defend else, which means you're destroying the player whenever obstacle has been collided without talking the points or without reducing the point. Therefore, in this case, this world. So now it's zero to now. When I collide, you can see new high school is too. When I click replay button, you see high school is too. It's a bit of scene until you make eye school as three. Let me make it three. So one to on Don't know this that the Tunis not being played over here the main to it only gets played on continues playing When you come from main menu toe the game scene Now I exist it with the obstacle. Now you can see new high school is five It re pains seen even when I replayed again High school will be fine so that's so If you are comparing the points on then reducing it you need to compare the time for Mr Player has played the game for time Thing will treat a float time variable on well threat I and numerator will call it a timer on inside This here was you written new wait for seconds so we'll wait for one second on increased the time in the start matter with That's death, Corti. So it's a start, Gordon. According name was Timer. Yeah? What justice? So here we are. Starting recording timer In the start function, this Gordon gets started inside the score. Teen, We are waiting for one second on then incriminating the time value when we have implemented with static Orting again. This behaves like for Luke. But this is not for low. It just loops. It waits for one segment on that increases the time value. So initially zero has started called enough. The one second it will be one I started again after one second. It will be too on after the other 2nd 3 and saw over here I'll took If time is good Plan, player place Start getting time as I'll be incriminating by one. This will be off end. I don't need a flute. So as a time Andi time. If current time is created than the store time on displaying it on storing it. Because this is the new high school New time, right? Yeah. We go back to unity and set this out. So now the high school is 20. If the player dies now, high school will be 20 because 22nd is greater than the number of seconds in which we died earlier. So let me play for more than 20 seconds. Actually, this is not the time I'm displaying something else. I think across 20 seconds. So let me make the play and die. Yeah, you High school study. Eight seconds. You can see the 38 even if you replay the game. Fantastic. If your high school system is based on the time just at a text in the help panel saying high school in based on time so that if you survive for longer duration so use of survive for longer duration so you should survive for longer duration in order to make make another high school longer duration, you can sit down the previous time to make it move here you can increase its size. Yeah, if your high school is based on the points you can just included here, High school is based own points. That's it. So here I just include or change its color to purple on inclusive size to 20. Recite. It's yes now disabled help panel servicing can 40 14. Building our game: they give them the post. So Shankill from San Sobs and this video will build our day. So to build, only just go to file the settings on, then drag and drop all the scenes into the bill settings. Make sure the scene which you need to load first when someone opens your again, will be at the top if it's at the bottom or some medals just ragged. Talk now. If you want to build your game for Windows, Select Windows on the architecture. Er, this is nothing but 32 bit on 64 bit, then taken place. Settings. I'll Dragon Doctor, over here, Alan. Last this your unity window. Your company. I'll say that Sands Arts on over here. You need to enter the game name or the product name. I'll see Space Runner on all hell can just set the game version or the product wasn over here. You can select the game icon are the product I can on just selected to this right. If you want, you can choose the cause of Sprite, then go to resolution and presentation. If you want to run the game in full screen, more select full screen mode if you wanted to run on widow more the select window Al just selected the full stream window. If you selected the window, you can set the resolution off the game over here on. Then if you want toe displayed a solution dialogue where the game or can choose the resolution of the game select. This has enabled. If you don't want a player to select the resolution again, choose this as disabled. Then go this class image on his tribute here you can see the unity you go when I hit the preview button. This will be sown first when someone opens your game. If you don't want this blast green unit toe by unity plus or unity pro If you want your local Toby displayed this cake on display list button and then drag and drop your sprites. Here you can set the local duration on your return trip You believe on display your logo if you want it to be secret Shit. Just select remote to all sequence you now locals will be displayed one after the other. Here you can select the animation style this blast style, the color on if you want even the background image. I don't want any background image on in the other settings. You need to enter the bundle ill and require Oh, first unity entered the company without any space on then the product name that sits. Now you're ready to build your game for Windows Mac on Lenox. If you want to build for Windows, just select Windows and it Bill. If you want to build it for Mac Lennox and Roll or Red Deal or any of the platforms of this available over here, you to click on open down the beach on download the bloody all you can just open the unity installer off this same version on enable the leggings, which you need then installed in. I have downloaded the plug ins for this was enough unity, so I'll be showing you how to build your gain. And this was an off unity. It will be the same even in that was enough unity. So if you want to build your game for Lennox, just select Lennox on the architecture, then Bill Yogi. If you want a video game for macro sex, select Marco a sex, then hit bill. If you want to build a game for Android Selig Bill system to internal in the player settings. Enter your company. Mean Rodney if you want to cancel it, the icon in the other settings and that the company name and the product. Lee. If you want, you can add your own splashed image in the solution and presentation. You can sell it be default orientation, which means if you want oh hello, the player to run your game, either in portrait or in landscape mode. Just study toe altercation. If you want a clear toe, run your gaming landscape more. Just select landscape. If you want to allot a player to run your game on portrait more, just select portrait. I won't get Toby Landscape Left If you're building your game for android, make sure you have downloaded hundreds studio as it has a sneaky tools, which is required to build a game for android. Install and urge to you then goto edit trances on Over here. Direct external tools roll down here where it says a sneaky the select grows and select. The sneaky folder that will be installed by the and roads to you on will be stored in this location. It will be stored on the APP data. So at the address bar, type up data become AB data, go to local and roll on select Sneaky You. We will need to install job are very K to install Java and take on post. Go to the style directory, said Derycke on Git Select folder. And then you can build your game for Android on, then hit Bill. If you want to build a game for us, just us Selig orientation, I can enter your opening product. Lee. If you want, you can add this placid mates on hit build. If you want a 1,000,000,000 for Web gel in the solution and presentation, you can set the resolution off the key on if you want. You cannot use class image that sit in this way. You can build you again for any platform, which you need. Thanks for watching