Monday, 9 February 2015

interactivity - Setting up the scene

For this subject we have been asked to create a space shooter game in unity like this one

All the materials have been pre made for us so we jsut have to code the game and publish it.

Here is how i set up the game, added a background and positioned the cameras and lighting


  1. create a new project and import assets into the project window  - Assets are a bunch of objects you can use to create the game such as 


  • 3d models 
  • A Texture is applied to a Material
  • A Material is applied to a GameObject (with a Mesh Renderer Component)
  • An Animation is applied to a GameObject (with an Animation Component)
  • A sound file is applied to a GameObject (with an Audio SourceComponent)

  • assets can also be found and downloaded in the assets store on unity. 



    2.  set a build target  - this tells unity what the final outcome of your project will be played on  for this project we will be using a web player for the final outcome. 




    3. Then the build details need to be altered to fit the correct outcome, in this project we want a 600px with by 900 px hight to give it a portrait look. There setting can be adjusted in the player settings pannel. To see the game in the correct orientation we have to go into the game mode and change the aspect ratio to web view. 


    4. Then i went back into scene mode and draged the space ship from the asset directory and placed it in the scene. Doing it this way automatically adds it to the games hierarchy. The hierarchy contains 
     ever game object that is in the scene, you can also create empty game objects in here to group together items to keep organisation clean. If you double click on an object in the hierarchy it zooms into it so it is easier to find. 

    5. it will make coding the game eaiser if the ship is positioned at origin, to do this click on the ship and go into transformation and rest it. This should move it to x0 y0 z0

    6. we now need to apply physics to the ship to make it move correctly we can do this by using a rigidbody, This  Controls of an object's position through physics simulation.Adding a Rigidbody component to an object will put its motion under the control of Unity's physics engine. Even without adding any code, a Rigidbody object will be pulled downward by gravity and will react to collisions with incoming objects if the right Collider component is also present.


    7. a collider is then added to the ship to  allow it to react with other colliders ( the asteroids ). There are primitive collider such as capsual, box or sphere  which create a basic mesh around the object, or mesh rendered colliders that can be added wich use the exact shape of the ship.  How ever mesh colliders as they have a more complex structure can sometime preform worse then the primitive colliders. For this game we do not need full physics collisions we only need the collider to triger an action which we can change in the colliders settings.





    8.  In the assets i downloaded there was a pre fab that contailed a particle system that could be appiled to the ship to make it look like it was powered on.  A pre fab is an asset type that allows you to store a GameObject object complete with components and properties. The prefab acts as a template from which you can create new object instances in the scene. 

    9. Now the camera that was currently in the scene needs to be moved to face down wards above the sip we can do this the same way we moved the ship, by going to transform , resetting it to 0,0,0 and then rotating it to look down on the ship. 


    10. The cameras component type then needs changing from Perspective (Camera will render objects with perspective intact.)  to orthographic (Camera will render objects uniformly, with no sense of perspective.)   The the cameras needs transforming again to make the scale of the ship small and be in the middle bottom of the screen.  At the moment the camera also had a sky box on it ( any empty space will be coloued in blue)  which for this we can just change to  a black screen for now. 

    11.  To make the ship stand out we will use a 3 point lighting system which a main key and rim light. This will show of the shapes of the objects and create atmosphere. To do this i used 3 directional lights and rotated them around the scene to brighten up the ship and create a shaddow on one side. 


    12. using an empty game object in the higharcy i can group all the lighting together and move it up out of the way of the ship. As they are directional lighting and offected by rotation not position they can be moved around the scene out of the way. 

    13. now we can add a background to the game, to do this i need to create a quad this is a primitave shape you can build in the game. This also needs transforming to be central to the game.  Then selecting a file from the textures assets drag and drop it onto the quad making sure the file size is big enough to cover the whole area of the game.  Doing this applies a material layer to the quad as unity needs that to render the texture. The quad then needs scaling to the size of the image to make sure it dosent distort for this image the  x is half the size of the y  or 1:2


    14. The lighting is currently too dark on the background how ever we dont want to add another light as this will mess with what has been done to the ship , so we can change the shader settings to make it stand out.  This changes how it is viewed in the render, it is currently set to diffuse which is like looking at matt pain compared to glossy very dull and lifeless. If we change it to specular it will look more glossy and bright. 


    15 . now the scene is ready to code the ship to move around the game 



    No comments:

    Post a Comment