Importance of Natural Resources

Survival Shooter Tutorial – 1 of 10 : Environment – Unity Official Tutorials (new)


This is a top-down isometric style shooter game You are a boy who is having a dream that all of his toys have come to life. You run around, you shoot zombie teddies and other things, score points and eventually meet your demise. So that’s what we’re going to make and we’re going to be learning about the editor from putting together a scene implementing animated characters, AI, some of the new UI and lots of other stuff. It’s a very uplifting game, you can’t win, you can only eventually lose. So that’s the way we prefer to make them. The very first thing you’ll notice is that on my screen I have the project open. We don’t want you to have the project open at all, what we want you to do is to make your own new scene and we’re going to put this project together. So if anyone has got the scene open we don’t want you to do that, we want you to make a brand new scene. So first of all we’re going to go to File – New Scene. Then what we want you guys to do, to make sure that everyone’s kind of on the same page we’re going to ask you to setup the editor in the same style that we have. If you’re comfortable with Unity, if you’ve used Unity before and you prefer to work in your layout of the editor that’s totally cool, you can keep that. But if you’re new to Unity what we’d like you to do is to choose the layout menu in the upper right and choose 2 by 3. So layout drop down in the upper right and choose 2 by 3. That would get you a style that gets you something like this. Then what we’d like you to do is to drag the project panel and drop it below the hierarchy. You’ll note that when you drag the title tabs of the panels around they will dock in to different spaces. Drop that below the hierarchy and then you can just drag up the division between those two, maybe drag this over a little and then you should be all set. So hopefully everyone’s got a view like that? Then what I usually like to do is with the project panel, because we don’t really need to use the thumbnails particularly there’s a slider at the bottom which will change to list view when dragged all the way over to the left. So if we drag it over to the left you’re going to see exactly the same as what I have on my screen here. We are working with Unity 4.6 but right now what we’d like you to do is to go to File – Save Scene As and we will ask you to put this in to the Scenes folder. We don’t want you to use the completed assets version of anything just use the Scenes folder that’s in the root of the project. And we’re going to call this Level 01. So save it as Level 01 in the Scenes folder. When you’ve done that successfully you should see the name of your scene up at the top of the interface. Okay so the next thing we’re going to do is setup the environment, so I’m just going to show you that first. So a prefab, just to reiterate how this stuff works, a prefab is our way of providing or saving a game object in to the project. You can do that for a number of different reasons and we’ll be saving prefabs in order to spawn them in to the game later with the enemies. But for the purpose of the environment we prepared the model and a number of collider and other elements. If you look in the prefabs folder you will find a prefab called environment. Prefabs are represented by this blue cube icon. All you need to do is to drag and drop that up in to the hierarchy. So just to remind you, the hierarchy and the scene are intrinsically linked, anything that’s in the scene is therefore in the hierarchy and visa versa. Just make sure that you’ve got a decent view of this level. You can use the hand tool of course up in the upper left and use Control to zoom in and out and Alt to rotate around. We don’t need to worry too much about the view that you’re looking at in the scene view because we’re going to setup the camera to look at particular part of that later. What we’re just going to check is that we positioned the environment at the origin. So with the environment selected in the transform component you should see the position is at (0, 0, 0). If it’s not just fill that in, (0, 0, 0) or go to the cog icon in the upper right and choose Reset Position. Then once we’ve done that we are also going to drag in the Lights prefab. Lights is in the prefabs folder, you simply need to drag that in to the scene and it should light your scene. With the lights we don’t need to worry about positioning particularly because it’s directional lights. With directional lights you only need to worry about the rotation. So if I just show you those briefly you can see that these directional lights are pointing in certain rotations and they’re going to affect anything in the scene, you don’t need to worry about where they’re positioned. The way this game is going to work is we’re going to have a camera that’s looking down on the scene. And what we need to do in order to track the player around and also to be able to shoot is to use something called a ray cast which is going to create an invisible line from the camera to the floor. But we’ve got a very inconsistent floor, we’ve got a number of different environment objects such as these stools, the Lego bricks, the broken train and all these different things, so we don’t want to worry about ray casting on to those at different heights so to make things a lot simpler what we’re doing is we’re going to add in a plane quad. So what I’d like you guys to do is to go to Game Object 3D Object and Quad. What you’ll notice is this creates a very small 1 by 1 quad right in the centre of your game. We’re going to reset that to (0,0,0) in the transform component so make sure the position of your quad is at 0. And we’re going to rotate it by 90 degrees in the X axis. Finally we want this to cover the entire game level so we’re going to scale this by 100 in X and 100 in Y. We’re going to name this Floor. So rename from quad to Floor. So the next thing we’re going to do is to make this invisible, obviously you’ll notice that it looks pretty horrendous right now. We don’t want to actually see this. What we want to do is use the collider, so the outline of this shape. We don’t want to use this kind of grey for any reason at all. So a quad is made visible by the mesh renderer component, and because we don’t want that we’re just going to go ahead and remove it so with the floor selected click the cog to the right of the mesh renderer and choose Remove Component. So with your floor selected go to the cog icon in the upper right and choose Remove Component and you should see that you can then only see the collider outline. Make sure you remove the mesh renderer, not the mesh filter or the mesh collider. Remember you’ve got Undo if anything goes horrendously wrong but you should then see that you just have the collider around the outline of the level, something like that. Then because we don’t want our ray cast to check for anything but this quad we’re going to use layers. so a layer is a way of isolating things like ray casting or lighting for example, to a particular group. So with the floor selected if you click the Layer drop down you should see that we have a floor layer ready for you. Choose from the Layer drop down at the top of the the inspector, Floor. And then save your scene. The next thing we’re going to do is finish off our environment by adding some background music. With sound sources in Unity we can attach them to any object, it’s a component that you use to apply a clip to or you use scripting to assign clips to. We are going to have a separate game object just to keep things separate and just to keep them nicely organised. So I’d like you to go to Game Object – Create Empty and then rename this Background Music. Return on the Mac or F2 on the PC just like your operating system and rename this Background Music So we’re creating an empty and renaming it Background Music. Then we can add components to our game objects to make them do different things. So we have a component menu up at the top with a bunch of different categories of things that you can do to your game object to give it different behaviour of different functionality. What we’re going to add is an audio source so we can use this component menu or we can use the Add Component menu over on the right in the inspector. So because the inspector will show you properties of the game object currently selected we can go in to here and we want to add an Audio Audio Source We don’t really want to hear the music for this game playing every time you press play in your game but just to make sure that everyone’s worked we are going to do it once. So to assign a audio clip to the audio source we can use the circle select. We’re going to refer to circle select a lot throughout the day, it’s the small nipple-like icon to the right of the audio clip, and what that will do is pop up a context window which is going to allow you to find the file you need. The file you need is Background Music, surprisingly enough, and simply closing that window will assign it to that. For everyone’s sanity uncheck Play On Awake. We also want the music to loop when we are finished with the game, we do want it to loop so uncheck Play On Awake and check Loop. In the volume in the component there is a slider. And we can just drag that down to about 0.1. So that’s just to balance it with the other sound effects we have in the game, and then you can go ahead and save your scene once more. That’s the end of phase one, setting up the environment. The next thing we’re going to do is look at our player character. Subtitles by the Amara.org community


Reader Comments

  1. great tutorial, i totally got passed the first 2minutes and 53 seconds. thats sarcasm. how about a tutorial on a windows pc?

  2. My lighting is way off. The shadows are barely visible and it doesn't look like the video. In the video it shows two sun images, a white and red. On my side of the project, it doesn't. I have no idea how to fix it. Also, I continued with the tutorial and noticed that when I die, it restarts and the lighting is darker and I like it how it looks the second time around, but it always changes back. How to keep it the darker?

  3. if you have problems with lights you need to do 2 things
    1)from Hierachy menu click on (Main camera) then from the Inspector menu uncheck (Allow HDR) this makes the lights in (Scene screen) similar to the (Game screen)
    2) from Hierachy menu click (Lights) menu then click in (Scene lighting) then from Inspector menu increase the Intensity to 1

  4. Ah, the classic game design model: No way to win, and it just keeps getting harder and harder until you die.

    Just like real life!

  5. So this game looks amazing. Why isn't it an actual game? Besides creating a game and marketing is the real reason we don't see very many good games in the industry because of hardware compatibility or something else we don't really hear about? Are we going to have to do an insane amount of coding to get games to work on every single combination of GPU/CPU?

  6. Survival Shooter Tutorial is no longer available. Have anyone had this assets? Please share with me 🙁

  7. In Unity 5 if you are having trouble getting the scene to be Darker, as shown in the video go under
    Window –> Lighting –> Settings
    and under environment lighting set the source to 'Colour', next set the Ambient Color to Black. exit the Lighting tab.
    now go to
    Window –> Lighting –> Light Explorer,
    and unchecked the on box next to 'Directional Light', now your scene should be sufficiently dark

  8. This project says it's going to take around 20 mins to bake the lighting so I either have to play it with very little illumination or wait for that time just to see it properly. That's seems a bit counter productive.

  9. For all those struggling to find that scene folder, After you load the tutorial project hit the close button. It will prompt you to keep or discard. Click keep and select another destination folder for the same. Once that's done open the folder and search for a '.unity' file. Open that. Then create a new scene and save it into the scenes folder. It'll work!

  10. I am first at this listen. I don't know why we must uncheck the "Play on Awake" button.
    I can only hear the background music while I check this item.

  11. To get the gun to point where you aim, not slightly behind (as seen from the camera) you can move up the floor to about 0.6. It's not where the ray intersect the ground that is interesting to use, but where the ray intersects a horizontal plane close to the center of the enemy and where the gun is.

  12. This could be wrong way to do this but it removes the "There are 15 objects in the Scene with overlapping UV's. Please see the details list below or use the 'UV Overlap' visualisation mode in the Scene View or Object Maps for more information" warning! Now Under the Environment starting with the Blox click it and in the Inspector under Mesh Renderer go to lighting check off Lightmap Static on ea one that should remove the overlapping UV's. remember this might not be the way to do it but I couldn't find any one telling how to do this, And I hate seeing errors or warnings. if you know the right and best way please comment below to help us newbies out. Thanks a ton.

  13. Everything's working fine on the 'scene' part, but nothing's showing up on the 'game' part. It's just empty space. I'm on a Windows PC, any help? Thanks. 🙂

  14. When I try to save scene in asset folder appears a notification “the scene needs to be saved inside the assets folder of your project”. I can’t save scene please help

  15. It's 2019 and I assure you this tutorial is still applicable. I was able to get the game to work in the end. There were a few small changes that had to be made since i'm using Unity 2018.3.9f1, but this tutorial is very helpful and it does still work.

  16. If you get error CS0234. If you may be using the old version of the package manager. Go to Help > "Reset packages to default" should help.

  17. Please make a survival shooter tutorial for Unity 2019 it would be awesome
    "Please note this project has been marked as LEGACY. The contents of this tutorial may not work correctly with the latest version of Unity so please download at your own risk.
    "

  18. Hi everyone, I spent over 4 hours trying to solve my problem with Floor, I saw that there are many people who also faced the same. I managed to solve it, infleslismente did not stay the same way as in the video but it is working. I simply edited in the code the phrase "floorMask = LayerMask.GetMask (" Floor ")" and replaces the floor with UI, just as I also changed the layer from quad to UI.

    Oi pessoal, passei mais de 4 horas tentando resolver meu problema com o Floor, vi que há muitas pessoas que também enfrentaram o mesmo. Consegui solucionálo, infleslismente não ficou da mesma forma que no vídeo mas tá funcionando. Simplesmente editei no código o trecho "floorMask = LayerMask.GetMask("Floor")" e substitui o floor por UI, assim como também mudei o layer do quad para UI.

  19. I'm just trying to learn FMOD, and installing older versions of Unity and dealing with all these "this thing doesn't exist" kinda feels bad :/

Leave a Reply

Your email address will not be published. Required fields are marked *