ARKIT & Unity 3D, creating Augmented Reality Apps with C# - Learn to code by making your own AR Game | Sebastian Armand | Skillshare

ARKIT & Unity 3D, creating Augmented Reality Apps with C# - Learn to code by making your own AR Game

Sebastian Armand

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
31 Lessons (2h 19m)
    • 1. Intro

      2:26
    • 2. Requirements

      1:18
    • 3. Unity interface

      6:30
    • 4. C# first Script

      5:01
    • 5. Variables & Methods

      3:42
    • 6. If & Else

      6:29
    • 7. Arrays

      2:07
    • 8. Loops

      2:20
    • 9. Accessing Other Classes

      2:37
    • 10. ARKIT Plugin and running the App on our Iphone

      4:49
    • 11. Import of the first Assets

      2:38
    • 12. The Animator Controller

      1:58
    • 13. Moving our GameObject

      2:50
    • 14. Collision, Collider & Rigidbody

      6:00
    • 15. Damage Effect on our Canvas

      7:31
    • 16. AudioSource

      2:02
    • 17. Giving the player life & adding "GameOver" scene

      6:13
    • 18. The SpawnController, instantiate the zombies

      4:40
    • 19. Raycast, shooting our enemies

      7:31
    • 20. Particle System, making our own Blood Effect

      7:52
    • 21. Adding another Effect & Force

      2:32
    • 22. Adding more AudiosSource's

      2:17
    • 23. Testing the App

      5:44
    • 24. Adding Ammo to our Canvas

      3:39
    • 25. Creating the Ammo Script

      4:25
    • 26. Adding weapon & MuzzleFlash

      3:16
    • 27. Setting reference from Script to MuzzleFlash

      3:16
    • 28. Animation - Creating own Idle Animation

      6:59
    • 29. Pickup weapon from ground

      7:03
    • 30. Adding a shell Script for our Weapon

      6:55
    • 31. Creating a portal to another Dimension

      6:39

About This Class

Become an Augmented Reality Developer!

This Tutorial about Augmented Reality shows you all basics about Unity3D, coding in C# and the ARKit Plugin in less than 3 hours!

Why should you learn something about Augmented Reality?

-Augmented Reality is in it's early stages.
-There is still much potential to create awesome Applications.
-The demand for Augmented Reality apps is bigger than ever before
-Break into a brand new industry expected to be worth $165 billion by 2024
-The world tracking of Apples ARKit is amazing

Thanks to the powerful GameEngine Unity3D combined with C# it's really easy to create Augmented Reality Apps.

In the first 30 minutes we will learn all the important basics about the object oriented programming language C# combined with Unity3D. 

Then we will create the main project from scratch! You will learn all the important basics about:

-ARKit Plugin
-Raycasting
-Animation
-Animator-Controller
-Audio Sources
-Unity UI-System
-Particle System
-Moving GameObjects
-Instantiating GameObjects
-Scene Manager
-Physics
-And much more

So what are you waiting for? Be one of the first person ever who will create Augmented Reality Apps like this!

Transcripts

1. Intro: you everybody. And welcome to this video This curse is about or mention relative. And before we gonna have a look at what this cruise, everything contains, I will demonstrate use the main project. We will coach here from scratch. We will create an augmented reality. First Prison, Trudeau's arrival game. That means you can initialize the gaming, met in the real road wherever you want, and then you can interact with see enemies and items like an call off duty or left fraud it . But this is the real birth. Have you ever seen something like this before? We will create this protocol to re nozzle dimension as rather. And to make this possible, we only need an iPhone, other technologies on a similar level like they're Microsoft. Oh, Leon's needs for a world raking like this. A lot of sense does. But Apple zarek it only needs software for this and sings to the powerful game engine Unity combined for FC Shop. It's really easy to create augmented reality apps like this. Even if you have no coding experience, there's no problem across. I will show you in the 1st 30 minutes order protein basics broad see shop combined or if you achieve, and then we will create the main EP from scratch. And sheer will also learn also important futures off unity, for example, of boat ray costing animations any mater physics instead creating or moving game objects. Particular systems unities, rise system seen many draw audio sources and much more. And this address under three churros. So what you like to be one off? The first person ever will create apps like this. Then what are you reading for? 2. Requirements: and this video a show you the tools and software we need for our project. So first we need a physical iPhone six s or in Europe. Otherwise we contest are because to assimilate are a project. We need the camera off the iPhone. Next we need X cold nine. Type in Google X Code nine and click the first link Click Years Britain Download and look INR. If you're apple i d. If you don't have an account here than first, make sure that you create your new run and then look in and under release off there. Simply download and install. It's called nine and at last we need, of course, game engine and this cruise we will use unity three D toe Donald Unity. Click here on Get unity And here you get unity for free click try personal I think at this moment you don't run more than $100,000 in the year with your EPS. Therefore, don't nodes the installer here And no, just problems that don't know assistant. There was nothing special does addressed a normal installation 3. Unity interface: So, first of all, what we do know is we're gonna have looked at the interface off. Unity across its can be really hot when it's the first time you work in an environment like this. Therefore, I will give my best to explain your stuff. That metaphor. No, at least let's give Orebro Jake the name I called a test project. If you want, you can change here the location of radio store the project, but I don't change your anything. And in unity we can create three D and two D games. Augmented reality apps are off across three D games. Therefore, let's make this test project also true. Three D game and yet let's get started. If you start unity for the first time, your interface should look like this. Let's start with the menu bar on the top here. Here, you can do the stuff you can do in all the arts affair, for example, safer open the project or the scene, creating or importing different things that are available and unity or changing. Here's render and stuff like this. People die from this deeper later or envy creates a 1,000,000 project. Then here we have control tools. For example, if you changed if you know and when we click the hint year we can change view off the game , seen then really important period for hierarchy Bow in the Hierarchy bar are all the game objects. Revenge. A scene I'm the scene is this year. At this moment, you only can see two game objects, the main camera and the directional light. The directional light is like the real song. This makes shadow over game objects. We really see this, and if you were seconds and then we have here is the main camera. You can see the camera Prevue. This year is the same like this. This is a game you and this is the shoe for very. Or see the game later in action when the game is ready. And then also really important here. The inspector, when you're ever game object selected, and then you can see here all the components off this. For example, let's create a new game object. Let's create a new cube for this. You can go on the game object three D Object Cube or you make a right click in the hierarchy Bow three D object Cube. And here you can see now all the components off or cube under transform. You can change position, rotation and size. For example, If you change this very years a bit or if you want to make this bigger, we also can reset everything. Then we will make right click, reset position, rotation or skater. Then we have here a mesh filter row. This is restaurants, a form we can change this Azrael, For example, If we click this button here, if you want us feel we click on this and your currency is changing, then we see here a measure on Iraq and the measuring rod is the material. This is only for the correct fix year. For example, if we disabled us, you're currencies, right layer is gone. And then really important. Here is a box collider. This is something what we need really often because with the box collider, we can interact roof as our game objects what this means. I surely this in a few seconds. And if you want to read more components, you can click here on ed component. Here are a bunch of things you can add. For example, script, audio source or physics and stuff like this. Um, let's click on physics. And here you can see, for example, the box collider. But is their body fall? Let's add the rigid body and Rufus a rigid body. We can give our game objects physics like unreal, for example, immense Drake or Karev ity. If we want to test what components off our game object are making, we can use these buttons here. This is the start seen pro scene and skip to the next frame button. For example, if I started seeing, you can see here is a game for you and in the scene that the cube just fall down. This is because we enable us gravity on our rigid body, and because we have no third phase with did the Cube can interact. If you want to change this, we can create, for example, another game object. Also right Click three d object plane. If he's changed a position off the blame, you can also see the shadow no, and explain his collider. This is important because if you start to see no again, you can see the Box Collider Interactive's mesh Kaleida if you want, you can also change the view for this. Hold old, then you concede the change here the button. And then if you click the left most button, you can change the view. Then here below we have the essence. Old Oh, this is just a folder on our heart Rife. We safe here. Old stuff we need for our scene. For example, Models, audio sources, scripts or scenes Prize. Ray, if we want to save two seen, we can go to fire Safe scene. We can give us the name best scene. Then you can see this in the exit swallow and then behind to step we can see the console. This is a really important future is ready with course Here we can do, for example, print statements If we want to test something in our A script toe, understand, brought, happens win or any time there is an era and unit you are a No A script and June achievable Printed to the concert for us I think for us beginning this are the important futures off unity. Of course, we have a look at more futures in the next videos, but I think this is enough for Northeast. And in the next video we will talk about the shop 4. C# first Script: No. We gonna have a look at sea shop. First of all, I control your this program language with the basic compiler outside off unity. But this course is not abroad. See shop. And generally it's about teashop combined with unity. Therefore, I only show you here. Basics. A body shop. Richards useful for game development, sold. Let's get started to create a new script. You can go on the assets right click create C sharp. No JavaScript. Then you can give the script name. I called us for a script. If the script is selected, you can see here and the inspector about the script. Everything contains, but I want to see this group with an I D. Therefore, make a double click, and as you can see, this opens mortal develop. And, of course, you can use another idea like visual studio's or just normal a detour like nor pit. But I recommend record, and I d like model develop because this helps us a lot. For example, we have fear, syntax, highlighting, or if we write your something, for example, game object. You can see this gives us or medic the whole name, and some where were you and yeah, therefore use model developed. So every time we create a new project, unity provides this lines of code by default and see shop is an object oriented programming language. That means we are working here with classes, message's name, spaces and stuff like this. And for this is I try to explain, you know, let's start rift the name spaces in the first reliance off court. So the name space is rust contains a lot off classes and message that the unity engine provides. And if you write this name space here on the top, for example, using unity engine, then we make this curled on descript here available, for example, moral behavior. This is a class from the name space Unity engine. If we delete using unity and to know who can see the I d say stirs or something wrong across the script can't detect this cliffs anymore. And this is the name off our A script. This is also a class, but with this we interpret our new class the moral behavior, cliffs and rift. This class, On the other hand, we provide a lot off message or function, and this curly brackets here you already can see two functions year oId start Android Update. And if you want to get an overview, which methods are in classes available, you can go to the official immunity, documentation and sheer under classes. You can see, for example, our moral behavior class and she received, for example, or a start and update function. And you can also see Geo's our public functions and rare bills and stuff like this. What is available here? So let's talk about this to message. It's dot roosters start function, so to start function is called whenever you start the scene and really important. Only then, when the script is attached to a game object to show you this, we can write, for example, into start function, print and old Road. With this, we can print Heller word in the council here, toe testes you're seeing no nothing. This is because we have to attach this script to a game object. Refund the scene, no matter which came object, for example. That's gives the cubes in your script. We can at the script at component type in first script and selectors. And if we test to see no, you can see head a road instead of print. We can say De Bock look heavenward. This makes exact the same. Let's test us first. Let's clear the consul did play and next refused the update message. And what this makes is exactly what you can see here. This price ray equipment, you can write whatever you want. This has no effect raw script and your update is called once per frame. For example, your game is running roof 60 frames per seconds. Then accordingly, dysfunction will be called. 5. Variables & Methods: Now we're gonna have a look at Ray bills, and we will create our own function. So it's right, for example, public and health roost of public We can influence to help from outside off the script here , I assure you this this is our A script. And if we said the health Noto 100 for example, And if you want to print out the health in the consulate, we simply can say print. You can see our health is 100. If you want to create floating point numbers, we can say, for example, public float damage. We can also give Grable's a default radio. In the stop method, for example, damage is 5.8 float, and if we print this old, you're sear on new value and no, let's create our own message. For example, let's great and take message. Let's delete everything in the stock message changed image also to an intra draw. Let's a damage to five, and to call this message recently, have to say it. Take, That's everything. Now we can execute Croat and here, for example, Every time we have a knittig, we will decrease to health minus five. Let's print this out, but let's get your another wearable lets it. You're a string, for example, playoff his help life. And as you can see, the attack message is called and we have 95 life left, and instead or frightening here Friday, we can also take the damage. And this works with everything. You can also say, for example, health divided by damage or oh, last image. Whatever you need, let's delete the damage. We also can give our function parameter an argument. For example, I want to decrease the health on the take minors 10. Then I can simply say in the take message 10 and I gives the take message of parameter, and if we test is no, you can see our health is 19. 6. If & Else: No, we will talk about his statements and see shop. So for this, let's create your some new ray butts. Let's create a new string. We called a string player and we will call this player. I don't know. 90 and two. New Inter Draw Health. We will set this toe 100 and it lasts. Let's create a bullion. Let's name this player. Is the life bullion simply Rabel that can only have the value True or fourth? I will show you an example. And if you're seconds for what? This can be yours for. So to test if statements we will use the update message across this is crawled once per frame. This is perfect because if he changed values, then we can see this in real time. The Syntex off statements is really simple. Restock for food, then parentheses and curly briquettes. Let's copias a player. If the player has the name, I don't know that 90. Then we say G book, don't look player. Name is player. If we saved us and when we start the scene, we can see player name is Donald. 19 year across. This statement is true. Let's take another example. We were. Let's say if health is less for equal zero then we will say, Clara, is that your seat? This is frauds because health is 100. If you change the hope no, you can see Blair is death. We can give our statement more than one condition. For example. We make this in parentheses and then we say and Blair has the name Donald 19. Then we will say Player is dead. This has to re true. And this only then we can see this message safeties and let's testes. This statement is true and so forth. Therefore, we can cure see anything if you Shane Shields. The health we see are a message instead off and we can write this strokes with this we say this has to be true or this has to be true. Only then we can see there's let's testes. We see the message in the consulate because this statement is true. If we change this will, you know and both of them are frauds. Let's delete this statement here. We can also say helds. If health equals 10 then we want to say health This 10 we played a scene and nothing happened If we change knows the health failure. When our health is 10 then we get this message and it lasts. Let's do something Roosa bullion. If the health is less than zero, then reset the bullion player is the life before and no, we write the new a statement. If player is a life, just four words, then we will destroy this game Object. This is a message from unity and for this we destroy the game object which holds this whole script. In our case, this is the Cube because here's our A script and by default we will set. The Blair is a life bullion to truth. It retest is you know, if you change the health to zero you can see is a cube is destroyed. We can gives the destroy message the second perimeter, for example 10 And here you can see the summary off this perimeter. That means we will destroy his game object after 10 seconds and instead or player is a life equals force. We can simply say this exact same. That's safe and testes. We will send health to zero. I know we have to rate 10 seconds and then the cube is gone 7. Arrays: this video is a burled areas. Areas are ray or storing a collection off data off the same type together, for example. We want to create five and address. Then we could write and and the trouble one you could run in under drug tool because true and so on. But proof areas we don't eat this across. We can safeties values on lee and run area. So to be clear, an area first we need to say the type and after this, bureaus scrap records and then the name by its for example, And then we need to say there mount overuse, for example, we want five into dress Zimbru ride Fife. Then we can declare this Fife inter dress, for example, here in the stop method sold to initialize or a values we need the index. This is the inter try here in the group crickets and the index starts all the time with zero. So if you want to print out the free, for example, then we have to say friend, right and the index are three. This is two and every bladers you can see there are three A much easier way to create over into dress was following. Instead of writing, this year ends a stop message can delete this year and right curly prick, it's and then here we can simply say 12345 And if you want to print all the fright, no, for example, then we have to say, Been here for Let's justice and you couldn't see the five. 10. ARKIT Plugin and running the App on our Iphone: so no, it's time to create augmented reality application. So let's click here or new. I will call this summer shooter our epistle, of course. Three D game. And here, on location and on organization, I don't have to change anything. So let's create this project. The first thing we need to do is to import jacket for this weekend, grow in the acid store, type in our record and then click here this unity a record black in. So now we will have to download this black in. I already don't noted this so I only have two important. Once you have downloaded our record, you should have New Fuller here on the assets. The unity, our record Black in contains five example teens Interesting for us is only the unity our record scene. So make a double click on just to open the scene. First off, let's have a look on what we actually have here. Let's start with the directional light, the directional light iss like the real son. This will make shadow on all our game objects. Then we have here Random Cube. This is nothing special. This is only for the orientation because when we look at the game. You, The Rhythm Cube is in front. Off us. Important are only the game object camera parent and our air camera manager. Because this game objects are holding the scripts. Rich are responsible for the augmented reality. And also important is the hit Q Parent Across. This holds the script to place our game, object wherever we want. Then we have here the generate planes and the point crew. Particular example, objects and what they are making this realty in a few seconds because, nor we will run this scene on our mobile device to shake if everything rocks but the foreign tourists, let's delete this game object year. Of course, we don't need this right click delete. To run the scene on our iPhone, you have to go to fire bullets settings. Then we have to shoot our scene and drink and drop it in tutors window here. Then goto rs and click Switch Platform and also click here on player sittings. And here we can write the name off our company and the product name, and here we can give or bundle identify our name. The first year should have the name off our company and the second name off our product. And also make sure that you have, ah, string on the camera. Use a description and next weekend simply hit, built and run. Once the build is ready, a truth opened X cold. Better then you have to click on unity iPhone. And here it's important Toe truth. Euro team. Is it the first time you're running up? Then you have to get a new account here, also shoots euro device year and then click on play. If you have no arrows and everything is OK, then you should be able to run this app on your iPhone that arise. If you have some arrows pressing, you should shake this following shake the current requirements. In our case, you need immunity. Version 5.6 point two. I rest 11 and ex called nine better if you look this video in the future and you maybe need other burdens off this block in 14. Collision, Collider & Rigidbody: If the somebody has a coalition with the player, the player up is the main. Come around because this is over game. You then the zombie should make an take. And to do this we have to give our Sambi physics click the Zombie at Component Rigid Body and Box Collider. The rigid body gives overcame object a mess. Drake and credit to you. Let's change the position rival you. When we get Plano, you can see that the zombie has gravity. No re changed values off the green box. The box score The box collider should look like this so that zombie is in the middle off this cross re interact Rift Box Collider when we shoot the zombie or when the player I have ah, coalition grifters and the main camera needs Auto Box Collider Let's at the zombie another a script. Call this coalition roof from a rock Here we will call its re message. We will do something if we have enter collision with the main camera on the exit collision with the main tomorrow. And we also need a take message. This take you don't have to create because the take is there by default No. Let's check if this works for right in the bark Look and exit. Okay. I had an Earl. The all must be a tipping to off And also this year. And if we test this and as you can see, if we have a collision with our zombie the console Siri's enter on where we go Big safe exit. This is exact what we want next Let's create a bullion. Don't be, is there? If the zombie has a collision with the main camera, then we want to set this true And on exit we want to set this fall's And if we have a coalition so if somebody is there then we want to call the message Take We also want time between the attacks. For this we need floor timer and the inter job time between you Take the time between a tick we will set in a start function toe two seconds and in the update message we will create the time off to receive timer plus time. Did her time What this will make following. Let's print this out in the console. As you can see, we have a time off and this time out we will set back to zero every time if we have an A take. So let's take the time off and said, It's your victor zero No, we can give our, if statement second condition so we can say and the time out is bigger or decodes time between the tick. If this does only can on Leah, take the player every two seconds. And in the attack message, we can say no, get components, any mater and play Take with this. We have access to the animator and to the zombie controller. We have to add the take to go to components will be model and take the take animation and also make a right click on walk and make a transition to a take and from a take back to walk. This we need, because if we have a take, we need a transition back to the work. Animation as a rice of walk animation will not continue to play, and, as you can see, the zombie makes the tick and to walk. Animation also works 15. Damage Effect on our Canvas: and this video, we're gonna have a look at creating a demographic every time the zombie makes in a take so that we don't have ah, bloody screen on our game view. So on this screen here, therefore, we need an image for this open Google and type in bloody screen. Go to picture us and take a bloody screen whatever you want. I really was different here. Let's safeties picture and brought to say is I only uses image for this project to show you her weekend wreck Rift is, if you want to use this image later for UNEP in the APP store, then you should shake definitely the corporate rights off this image. Take this image and trade interruptus and all right. Yes, it's folder Click on this image and on the textual type truth right, Hit the play. No, we will create a canvas built to the high Ricky bomb maker. Right liqueur. I canvas Kendra's assembly layer on our A game. You're there on the screen here. Let's create a new image on the canvas, right click your eye image and under a source of much evil assures are on you Sprite and before we were. Let's get this image go through free aspect and truce, the height and the risk off your mobile device. Here, in my case, I use an iPhone seven s. Does iPhone wasn't there by any forward? Therefore, I editors and no, let's scale or a new image and what we do know us. The only enable or a dis enabled this image on the take. Let's go back to row. A collision script a possibility Hurrican Georges is following. Let's create a new game object. Bloody scream. Make a reference from the image to the script. Take the image interrupters on bloody screen. And no, we will enable this image instead. Take message. And no, we need to function that set our game object back to fourth after two seconds. The easiest rate to do this is Rift. The protein. Let's say it's dark or routine and the name off dysfunction. I recall this rate two seconds, then create dysfunction. If the function is called, then we will rate tour seconds, and after two seconds we will set the bloody screen back to fourth and by default we have toe disabled the image, so every time to sell me makes in the take, the bloody screen will be set. And then we also start a new protein and the protein. We will write two seconds and then we will set this image. Big toe falls, test result. And as you can see, this works. But we have one problem with this because later we want to make the zombie as a pre for in the S. It's water, I assure you. What happens then? As you can see, it's a reference from the script was image is broken and if I want to set up this connection again, you can see this doesn't work. This is because in unity, prefects can only have as our prefects s referenced a solution. Hurrican fixes is following and sit off making the referendums to another prefab. We will set up the connection to a game object in the Iraqi bar. Therefore, let's create a new empty game object. Let's call this game controller. We also have to give our game controller and you take Goto. Take click on the plus and let's quarters came from Trudeau and it lasts shoes on you take and no, let's get to the game controller object in your script. I will call this game control a script and then descript people set the reference to the image. Let's say public them object. Bloody screen safety is and drink and drop the image on the bloody screen. And there we need a connection from the collision with camera script with the game Control a script. Let's go in a taped message. So every time we have an attack, we will call the game Control a script, which I named game controller for no. And in the game controller script, we want to call a message with the name some B A. Take. We really create this message in a few seconds, and we will give this message the program. ETA. Somebody is there. If you concede the any tourists A's, there is something wrong. Doesn't because we have to set up this game. Controller. Let's Tourist. So first, let's name the game controller, script, game controller, and in the stab message, you really create a new game object with the name, game controller object, and this game controller object will be is a game object roof to take game controller. And if we can find a game object Rift Take game controller Then we want to set up this game controller to this game Controller object. And we want the Component Game controller script. If this lines of crows we have a connection between these two scripts. No, Therefore we can create this message. No. First we have to say public because we want access to his message from outside off this class and are a message expects the parameter Willian Somebody is there. And now we can simply take this year. Pace doesn't dismiss it and Orange holds the authority. And at last he leads a game object. Bloody screen. If we test is no destroyed, also work. 16. AudioSource: No. Let's give our zombie salt effect. Go to the desert store, have been scream and free only, and click on this download and importance. First off, Let's at year some new photos. Rightly Crate folder. It's called This Strips Another Fold or So, and for the reefers, Let's go to the zones and through the audio effect on what you want for your zombie. My opinion. This is good Togo to somebody at a new component. How do you source and drag and drop this on the audio clip Play on Rake we disable and no, we have to decorate this audio source proof or a script. Go to a collision with camera at your all your source. Caldas. Take zone and we look red in your array into start function. We do this because I'm later we will have or zombie modern one only was source, but for now we only need access toe First index. So take zones across. The counting off race starts all the time for zero and all. Let's say it's a tick method. It takes owned, play a small mistake. It's get components and not get component 17. Giving the player life & adding "GameOver" scene: this video we will give or play out life. But first, let's import some Aikens for or game s in store PS. I can this'll one here is good Goto canvas and create new image. Let's call this health and truth this picture. No, it old and click this window here. We want to fix this image at the top left and also a credit in your takes on the health. We will have 100 start life changed his height. Let's change the caller to write. Let's make the frontal eyes bigger. Let's also add another front for this. Let's go in the asset store again. Type in dry for your only. And let's important unity samples because off the unity samples your way have some heroes. Therefore, let's delete the scripts off this project here. Goto scripts. I know we can truth. Huber ties When it's time, no gold toe game controller came control a script. Let's at a public text, health text and the public into draw health, the editorial say's there was something wrong does because we have to import the name space for this appropriateness. Let's make the reference to those health text at the beginning, we will set the help toe 100 and on the take he will decrease to health minus five. No real transformed this into trato strength. The player have zero life left. Then we will load the scene in over. We need to import the name space, borders and we must create the game. Holocene, I'm here. We have an error to fix this. We can do following go to the concert and here you can do Ah, double quick. This will bring you directly to the line of code. There's something wrong in our case. I'm here is dismissing and then you can clear the concert and all arrows are gun safety scene and the project and create. And you'll seen safety is as game over and into the game overseen. We only create the canvas river text game over. Let's make this right on a bigger and placed us in the middle. And under the game over, we created button your game. Make this bigger. It's also changed our image. Tow this and create a new script on the canvas canvas at component Load. New game open this first import name spaces Unity engine. You. I am practice. We have access to the button and to load other scenes we need references from the script was a button. It's a public. But you game. If we click the button, be real called a message Lords game. We have to create this message and she reload the new scene. Thank you. The name off this issue Unity are here. Steen and drink and drop this button on the script safety scene and go back to the unity are echoed scene and also go to file both settings and drink. Interrupt the game over in here. 18. The SpawnController, instantiate the zombies: as I already mentioned in one Off the Last Videos. We want to make the zombie as brief up in this prefects folder, and from there we want to instantly eight zombies in our game. Let's do this. Take the zombie and reckoned ruptures and the Prefects folder and delete the zombie from the game and no click on our host. Eight. Your parent and let's get you a new script. Let's name this one controller. You re create the public game object indeed, and the public button stop button and brought the name space for all the buttons and run V click or a stop button. We will call a message start and rolled great domestic it safe, descript and set up the connections and Corretja New button Goto Kendra's right click You're I button. We re called us Start game Face the front, the image, the roof and the height. Enter size off the text and Rick and dropped the start game button on the script and start in rock, we say invoke refuting small Zero flowed and five flowed. With this, we can invoke the message, and his class expects to parameter the flow time and to float. Repeat rate. The flow time, say's after how many seconds? The message fruit and broke for the first time. And the floor repeat, right? Only repeats everything great. Dismiss it and the spawn function we will instantly. Eight Zombie into was the game. So let's say Instant E eight, for instance, He ate. We need the 1st 3 parameters. 1st 1 is a game object. In our case, it's zombie. Then we need a position. The position we will create in a few seconds across. This will be a random position in that last, we need rotation. Right click. Union or law. Okay, great position. This will be a victor three. Position new victor in a random range between miners 10. Float and float. This is for the extra, you know, Falls arrival, you. And for the that, Will you testers old start game. Okay, As you can see, the Spawn works. But there was something wrong with the animation. Let's check this. Go to a prefab zombie zombie controller. I think we don't need this transition. That's the leaders. Click on the miners and everything. Brooks 19. Raycast, shooting our enemies: in this video, we're gonna have a look at shooting or enemies and unity by using Ray Cast Ray. Casting means that we will shooting old, an invisible ray starting at the position off the player. In our case, it's main camera and then in the forward direction we are facing. And if the ray hit something with a box collider, then we can get all the informations about this game. Object. Therefore, let's create in your script right leg grades C. Sharp script. I named this suit enemy. Let's direct and drop the scripts in the Scripts folder, so we need a public button should button and also the name space for this, and we need access to our main camera. Go to canvass and create a shoot button right leg Your I button called this shoot button. Let's delete text goto give you place this at the bottom, right click this window. It's old and click here changed the image. I will use your I missed because I want button invisible changed within the height, click the camera parent so main camera room and create under the main camera. New empty game object Caldas written and at a new component Shoot any me and make the reverence should button control button and main camera on FPs came If we hit the shoot button, we will call a message on short great this message And to shoot the rave, we can say physics right cost and there are a bunch off perimeters. We can yours for this function, but we only need the 1st 3 starting roof Origen. This is a starting point off the rate and Royal coordinates. In our case, it's the position off the main camera So the FPs Kim friends form position. Then we need the direction off Serey. Therefore, let's say FBs Kim don't transform dot forward and it last we need to hit import. This will be an area great cost hit and we called a sit. And in this area we will store all the information about the object we are hitting. So we need to say old it's this function will return true if we hit an object River Box collider. Therefore we can take the entire function. If dysfunction is true with the curly prick, it's Then we will destroy a winding me. We will instead create the blood effect on the position rez array and hits the game object . And if the rate doesn't it in any me, then we will load a shooting effect. But first, let's check. If this works, we can say D book. Look, it's transform name If we had testes and move the camera. If you should know, you can see in the council the name off this game object. Or if he had to, somebody, you can see the name off the zombie in order to destroy our enemy. We need another script. So let's create this Goto Free Phipps, a zombie at a new component. New script. I will called us any meat. First, people set up the life off any me. Then we will create a public message public because we need access to this message from outside off the script. This expects also a perimeter image to feed dysfunction every time we hit or enemy be real decreased health minus damage. And if the health is less than or equal zero, then the enemy you shall die. Grant this message and she re simply say, destroy game object after one second. No go to the script showed any meat here We need a connection to the script. Any me. So if we hit a game object, rift, a component enemy, the component any meat is descript here. So if we did our zombie, then we will feed this message. Roof damage. Create the damage. I give this a default damage off. 10. No, let's test is old. Print the health in the council to aim our enemies easier. Let's import across there to go in the store. Search for cross here free only and import this 1st 1 Here, go to Kendra's Great. A new image. Rename this and truth, of course there are will take this one here. 20. Particle System, making our own Blood Effect: The next thing on your list is creating the blood effect to create our own blood effect. We can use unities particle systems. Therefore, go to Yes, it's import picket particular systems. We will import the whole package. We also need some resource is for our own lot effect Open Google and type in free items PNG and click the first link. On this page, you can download free items, type and flood. And we won this year and this year. And also under this picture this one here I don't know all the items create a new folder on the assets. I named this picture us opened the folder and imports Aydin's First off. There are a bunch of things we have to change with the particular systems. Therefore, if you don't want to watch everything, then you can simply don't know the blood effect prefab. And at the enter off this video, as arise, you have to do following credit, new material right click red material called us changed a shutout toe articles. I'll far blended. Duplicate this and Rick and drop the blood. Aiken's the particle picture off. No, take the zombie and drinking dropped this in Oracene so that we can compare the blood effect with the zombie. Let's create empty game object. Right Click, create empty cold as blood one and make right click particular systems. Make the blood effect tour child off the dummy and reset the position. Right leg reset position. Correcto the picture us. Take the blood. Want material and reckon. Drop this on the particle systems and we named the particle systems Toe blood one. Let's change the duration. It was 0.15 the stop lifetime. The start speed and to start size change marks particles toe one goto mission at her breast and changed a shape. This tour zero and the radios enabled size or we'll lifetime. It's at a key here. Right leg at key. And let strange start color. No, duplicate the blood effect. Take the blood three and reckon Drop this on the blood to duplicate blood To take the blood pool first, Let changed size off blood free and under start size change to random between two constants . Change the duration and to stop lifetime on, say, by Marx particles on three and change under our shape. The radios and also changed a start speech and no, let's create a smoke. Perfect duplicates blood one called a smoke blood and grow to standard assets, particle systems materials and choose this particular smoke. Let's make the smoke bigger and let's change the start. Kahlo. Let's say random between two colors and let's make everything smaller. Make all plot effects as a Charlotte off blood one and this able looping on all game objects. Now remove the connection to a zombie, take the blood effect and reckoned ruptures in the high Ricky Bar. And we set the position off all game objects right leg, present, position and drink, and dropped the blood effect and our our prefects follow. Now you can delete the blood effect and for me and in our end, in our A script and in our a script, he credits the public game object blood to think, and every time we are hitting a raw enemy bureau instead, th the blood effect on the position we are hitting the enemy into rotation. It's normal. Let's make this to regain object and let's destroyers, after a short time, make the Reference safe area offering 21. Adding another Effect & Force: No. We reload a shooting effect every time we don't hit our enemy. For this, I uploaded your folder Blood and True Defect. Import this folder under s. It's And here I have the hit effect. This hit effect is simply a prefab from the standard assets. It's the flare effect, which I modified a bit. Therefore, take the pre fit and move this in the Prefect's folder, and from here we will instantly eight this game object in a Racine. Let's say public game object, including defict safe, tres Make the connection. And let's say else if we don't it or any mean then we want instantly aid the shooting effect. It's a position rez Ray hits the book school later, ref. A normal rotation. And then I also run destroyed this game object so we can make this entire function toe a new game. Object holders if you didn't go and let's destroy this game. Aldridge. And as you can see if we hit something River Box Collider Senza shooting effect is loading . It's also add everything, brother, rigid body forth for this. We can say if the game object we are hitting have a rigid body. Then we want at the ready body of fourth in the direction back road and this river force, we will set up who's 324? You're free hit, all right. Any mean, you can see there's only most bake. 22. Adding more AudiosSource's: Let's improved some your songs for this. People use off course. The exit store tire in blood throughout this free pick ege and type in Freyre free only and importance written songs. Pig Drink and Drop. The new Pictures in the Zones folder in Flint. Stop River Shooting Affect. Let's at the written run and your audio source. Drop the Friend Zone on the audio clip and make sure that your disable play on a rake at another or your source. And for this take the reload sound is able to play on Rick and a new owner. Your source. Trude Song and we load. So creating new every the chutes on is the 1st 1 and the reloads on just a second. For this time, you only need the chutes owned. Take the chutes owned and that's a short song. Play No Goto prefects Zombie at the Zombie, a new component OU source. Go to the black folder and taken all your thoughts. Whatever you want, I will use the 1st 1 disable play on a rig, go to rescript any me. We also need an area for this because we need access to the first index and on a hit real plate is sold 23. Testing the App: before we go on. Let's chicken this video if everything works up to this point or if we have some arrows. But before we can run the scene on or I form, we need to modify the scene a bit. Starting rift The unity, Our air hit test example. Make a right leg edit script. If you have a look at the update method, you can see that the script is shaking for a touch on the scream, and then the script transforms this touch and coordinate their problem. Norris. If we hit one off the your eye buttons like shooting or starting the game, um, then descript. Also, to take this touch and transforms destroyer a new coordinate and move the whole map to the u point. So we need through preventive. For this, we can say using you. Get to you engine rent assistance. Take this in parentheses and let's give this if statement second condition. With this, we say if we are over a game object like the your eye buttons, then we don't want execute Disc Roach here. This is everything for a descript. Safest and re ultra wouldn't destroy the whole unity area. His test example. Script If he clicked the stop button because if the game is starting, then we don't want to change their position off this house here and author people this able to start game button If we click this, let's stories go through this holes at a new component new script named this start game. Here we needs the public button stop, but a reference to the script. And let's also disable the crossfire of by default. And let's enable the cross here. If we click to stop button, let's brought the name spaces. If we click to stop button, we will call a message. Start a new game here. We need access to a script because we build destroyed a script. Then we sent to stop Game button to Fourth and the cross hair to truth. Set up the Referendum's Krosa on cross area and that game button on start button testes. If you click this stop game but know this script here should destroy, you can see it's gone and the Corsair is there. Now we can run the scene on your iPhone. Therefore, goto file build settings and prefer we run this EP go to player settings and change under resolution and presentation. The fourth orientation toe Lensk eight left and all hit, hit and run. She was your team. And make sure that you are opening the latest version off X Code and not the normal ex Corde because then you will have an aero here. Then you can play the scene. I think there are some things we can do better. First off all, I don't want this shadow here under the holes for this weekend. Um, lift up the plane here and they're also think that the shadow of this is too extreme. That changed the strange off the shadow. I think this looks good and it last goto the written and let's decrease four. I think 150 is enough. 24. Adding Ammo to our Canvas: in this video, we will continue with our shoot enemies script because there are a lot of things where you haven't done yet. So let's at a moon for our grip. No, let's start with the cameras at a new image. This image will be the big grown for a weapon. Therefore, I shoes for this. Um, ask. Let's disable the start game button for no call this image Weapon one and changed the size at a new image. Trees Britain one to use the handgun. Make this also bigger. I quote. It's written What an image and, no, let's get the text for the arm right liqueur I text name. This takes changed informant and the front size. And of course, the risks and the height duplicate. I'm a text called us More takes, too. Let's make the front sides off the ammo text, one of its smaller I think this is good. So takes a written one Collectors window. Hold old and click at the top right? And let's move to the whole image. Let's that another image gold of grenade. That's also true for this image. You're I'm esque and the new image you. I image and truth this and moved His image duplicates a grenade quarters, health kids 25. Creating the Ammo Script: No. Let's make reference from this text toe our weapon one should any means script opened the script. It's all it's a public takes a more one text and I'm on to text. We also need to inter dress and I'm all too because in descript we only can broke vistors to inter dress and not riffs, um, or text. And I'm a tour arm. I want to takes a normal one. If there's a default value off 20 and are more tour, we will give 100 every time we should. We really decrease broke off, then minus one and no, let's transforms almost back into a string. And I'm a one text which is this year so dispel you retreat transformed here into a string and the same for our motew. With this, we are able know to see Israeli years off are almost on the cameras. It's tested. This works but here is ah, string missing. Let's at this. It's on disposition here. As you can see, the radio off arm A one can also have minus valuables. This we have to prevent records, say here I'm a one, this one Then we want said one big toe 21. And if the whole arm or is zero, then we will set a bullion I'm on is empty. Too true. Let's create the bullion. And if the armor is empty, then we cannot shoot for this. We can simply take this whole quote here and said this in an if statement. So if, um oh is not empty, only then we can shoot, as you can see is the armor is empty. Then we can true anymore. But here is a problem with a more text. Let's fix this. We can say following if I want to zero. Then we will set. I'm a one So true zero. And take this statement. Paste is here, across people over right. This string gives the arm or one swing a new name. Also this year safe, tres and let's test if everything rocks 26. Adding weapon & MuzzleFlash: No, it's time to report a weapon for our screen. For this, I uploaded you hold a weapon pick, take this folder and drop this on the assets. And before we will continue, let's clean up the essence. Fuller obit The scripts to a scripts, the game overseen toe scenes, the zombie controller toe animations, this two components and no open the weapon. Pick. Take the pistol prefect and drop this under our weapon. And let's change the values. No opens a pistol prefect and let's change. Gears are material. Click on a beetle, type in heads and take this image and this also for the weapon participle. IWant the spreading picture. No, let's create muscle flesh for just we will use standard s it from unity. Go to restore. That is, it's particle systems pre fabs and create under pistol, a new empty game object. Hold of this that's a little pro to receive and reset the position. First, let's delete the sparks and moves the whole muscle flesh towards the gun. Here. Let's change the racial also from the smoke, and they're change under emission rate over time and from the flare and at a breast. But really one end. Run and lead. Change this muscle effect. Go to the new record. Take click this empty material shoes, this muscle flesh Northrop this on the flare and changed a position off the smokier us to play with the failures a bit. I think this is good. This able looping. 27. Setting reference from Script to MuzzleFlash: No, it's time to report a weapon for our screen. For this, I uploaded you hold a weapon pick, take this folder and drop this on the assets. And before we will continue, let's clean up the essence. Fuller obit The scripts to a scripts, the game overseen toe scenes, the zombie controller toe animations, this two components and no open the weapon. Pick. Take the pistol prefect and drop this under our weapon. And let's change the values. No opens a pistol prefect and let's change. Gears are material. Click on a beetle, type in heads and take this image and this also for the weapon participle. IWant the spreading picture. No, let's create muscle flesh for just we will use standard s it from unity. Go to restore. That is, it's particle systems pre fabs and create under pistol, a new empty game object. Hold of this that's a little pro to receive and reset the position. First, let's delete the sparks and moves the whole muscle flesh towards the gun. Here. Let's change the racial also from the smoke, and they're change under emission rate over time and from the flare and at a breast. But really one end. Run and lead. Change this muscle effect. Go to the new record. Take click this empty material shoes, this muscle flesh Northrop this on the flare and changed a position off the smokier us to play with the failures a bit. I think this is good. This able looping. 28. Animation - Creating own Idle Animation: No. We will create our own Idol animation for the Britain. For this click on or a pistol The cross for our animation, we only need to change this millions. Then click on the window Animation parades, the animation, Korda's idol. Any nation we only have to set a few key frames a disposition are want. - I think this is a good idol. Animation, No open under pista. Any made our controller? And, as you can see, the animation redressed created is here. And if he Creek Plano, you can see the Idol. Animation is playing. And no, if you click the shoot button, we need fire animation. Click under a pistol and take this for animation and the real old animation make from Fire Transition, Big Toe Idol animation and from Idol animation to reload and from reload Big Toe, I'll animation. Let's Go to our Should any me script? Okay, first, we need a reference from the script. Tow this pistol because we need from this game object the component, any mater. And now we can say on Trude, we want this game object from there, the component animator and then we want to play the fire animation to free our animation. This this animation. Let's click on the transition from Idol animation to reload and disable his exit time. No, let's testes the fire animation works, but in my opinion, the animation is a bit too slow. That changed us. Go to the animator on the frail animation and here we can and friends Speed, Let's say, for example, Tool No, let's make the reload animation go to script. What we want, you know, is if our number one is empty Onley, then we want players a reload animation. For this, we also need the game object pistol game object from there. Also the component any major and what we do know is new because we will set a trigger. The trigger expects parameter. Let's create this. Go to the animator controller and under permit us create New Trigger named this reload and no click on the transition from Idol animation to reload and here on conditions click on the plus. And here we can say the reload animation should only play if the reload trigger is set. Testes. This works, but we have run problem, as you can see if we don't rate for the reload animation. Then we can skip this. Let's prevent this. Go to rescript. Let's give our statement the second condition. That's called us. Reload, Shake, reload. Shake is a bullion, and if we play the reload animation, then we will set this bullion to fort. It means in the time we are playing the reload animation we can true anymore. But if the reload animation is ready, then we need to set back the reload check bullion to True for this weekend. Jules Unities cover teen. Let's great dysfunction here we raid three seconds and then we will set this big truth. And, as you remember, it created a real old sound. Let's players on reload and let's set the reload check too true by default. Otherwise, we can't execute this year because reload shake isn't true. Before we test this, let's change this molting go to pistol, mussel, flesh flair and disable play on a rake. This was responsible for the muscle of flesh effect. If we click on play 29. Pickup weapon from ground: in this video, we will call it the script to pick up this ribbon from the Croat. So to make this more realistic, to do this, we need, of course, written. Therefore, all go in the acid store, type in pistol and click free only we want this ribbon don't load and importance opened the new folder and make the pistol as a shy it off. This Charles moves the pistol. Let's change the rotation and let's make this bigger. Remove the Animator and Editor Books Collider. Decrease the size off the Books Collider. We also need for a written a rigid body because I want physics for this so it component rigid. What do you we want Karev ity for or a weapon across? If we had play long, you can see the reverend dropped on the ground. And also, let's rename this ribbon two pistol and no, let's cross the script to pick up this ripping from the crowd. We will lead the main camera. A new script Cold is pick out Britain and descript people. You're something that you should already know. We will use own collision enter and one collision exit. Let's say if we have Ah, Coalition River game object off the name pistol. Then we will say in the consul entire test and the same we need on Collision Exit Safest and go to Timor Apparent main camera. And it is the main camera rigid body. We will disable years gravity and under here we will free supposition and the rotation and let's play the scene. If we have a coalition with the pistol, you can see the consulate say's enter test and exit test. Let's increase the mess off the pistol. Let's say 40. I uploaded your picture group this picture in the Essence folder, Click on the hand and truth on the textural type spread and hit the Bly, go to Kendra's and add a new button. I called his pick up, delete the text and change the image to on us bright changes over its and the height, and by default we will disable this button and what we do know is if we have ah, collision with the pistol, then we will set the pick up button to truth. Let's create this game abrecht and on exit, we will set this to fourth. Let's also make a reference to this cross here on entire, we will sent this to fourth and on exit to True. This works, but let's also do following go to cameras and in your script threatening pick up. We need the name space for the buttons we need are all picker buttons and our a game object ripping one. Let's just able to threaten me by default. Set up the connections Rep in one on Reverend one and pick up button on the pick up button when we click the pickup button. Then we will call a message repertoire. True and cheery. Only set this written toe. True. Let's also test this start game, and now if you click this button, then we get your weapon. 30. Adding a shell Script for our Weapon: The last thing that is missing for a pistol is every time we should. We want to. Instead, he ate shell at the position off the pistol here, so that is, looks more realistic. Let's stories go to the Essence store type in shell and click free only. And let's import this pick here first. Take the new fella and drop this under components and let's take this one. What, this in the high Ricky Bar? Reset everything and let's make the smaller and move this and our prefects follow. Delete this and go to our weapons script. First, let's at our shoot message some comments for a better overview. No, we will. Instead, he ate the show. Good. The shell is this game object. The position is the game object with the take position pistol. This take we have to create his imposition is not written. Pistol that should be is a position off the pistol. Let's at this take and truces take into rotation. We will set to zero, and let's make the reference to the shelves distance. And as you can see, the prefab is loading. But you can't see this year across. It's on this position here. Therefore, let's answer shells from physics and a script. Let's stop roofs. A rigid body at component, rigid body. Let's change for the mess. It is a drink. Let's end this a new script. I called this move show. We need access to the rigid body so we say Get component. Rigid body. The cross is update method. We will give Russia for us. Do you okay, safety trait. The rigid body on the rigid body. And let's disable use gravity. Let's test us. This works. But let's get a random rotation for the show. For this, we will stop the core protein and the stop message, let's say, is long. Right is true. We want rate 0.1 floor things and then we want great in your random importation. Let's testes. Let's add the shell, Karev et After a short time, let's start a second career routine. Okay, we will write for a 0.2 seconds, and then we will set the Karev ity back to truth and tears of you. Off course. I think this is good, but we also have to destroy this game. Object. Let's say after our two seconds and it last Let's it, Russia and all your source this able play owner Vache type in the search box shell and take your song What you want. I will take the first run and in our a script, let's rate for another time and and let place under sound effect. 31. Creating a portal to another Dimension: the last thing we haven't done yet is creating a portal. So the basic idea or we could do this is really simple because we only create an invisible raw And then we will place this world in front for a scene, and this will make the impression that we have a portal to another dimension sold it. Stop first, I upload you custom, shadow up the shed are in the assets fuller and no. We have to create a new material. Rightly great material called us in Visible War. And what we have to do now is go under a shadow shoes custom. MISC. This is the mess. I upload it. You type in here of brawn 999 And now we build credit and you cube morphed is a bit delete all components off this cube at a skin mesh renderers as mesh shoes. It's a cube, and now we take a ride in risible brought material and corrupted on or cube. Let's gave us a bit and no if he create, for example in New Cube and rent removed this cube behind a rock wall, then you can see this cube anymore. And this is exactly what we need for our blotto. So, no, let's don't want a new scene. Go to the exit store, type in people free only and don't and improve the 1st 1 here, go to the new folder. Opened the demo scene. Safe This project. Let's create a new empty Gitmo trick here. Orders Foskett, too. And take all this game objects interruptus under the hospital. It's crawl a bit. Don't and delete the first person controller. Kobe this game object and let's go Big toe Oracene paste the hospital under our host and make this smaller. Let's move over. Invisible world in front. Off this hospital duplicate is cube, and, as you can see no, we only can see their entrance off the hospital. No, it's also at the gate for a scene in which we can place in front of this year, Type in gate and click for your only. And let's don't Lord this run. No, let's go to the new folder Goto scenes and opened the scene. I only want to skate from the scene. Therefore, hold shift and click the components off the gate here. That's also take the stones here and then make right click on the components and cooperators and let's go back to our scene. That's great year. New empty game object. Cold this gate. Make right leg and faced. Corrupt this under as a gate. And let's make the smaller and trump the gate under the holes that changed her reputation and Houthis in front of our reporter. Let's move the more of it and no, take the roads and drop this also under the holes. Let's duplicate the torch, and let's also move this in front of our gate.