At first we need to choose which platform are we building from
like Android, Windows etc.
Go to File
dropdown and choose Build Settings.(or ctrl + shift + B)
Now if you want to build for Android, you can choose Android
Platform and click switch platform button below n wait for Unity to switch close
the tab.
In the Game tab,
choose 800 * 480 resolution.
Now in the Hierarchy on
the left we can see two objects Main Camera and Directional light.
You can right click below and choose UI - Canvas, a canvas is created.
Basically canvas is the parent for user interfaces like
image, buttons and slider etc.
Select the Canvas and in inspector tab choose Screenspace- Camera in Render mode and drag the main camera and leave it in Render camera option and choose UI scale Mode to Scale with screen size. (Setting this will allow screen to change as per the devices installed)
Again Right click and choose 2D objects - sprites - Square and click it.
Now Select the Rect tool and drag the image so that it
covers the whole camera, canvas view in Game
tab.
Rename the Square to Background, by right click and rename..
When you click on Background in hierarchy, you can see its properties in Inspector tab on right
side.
In the inspector we can see sprites Renderer, we need to add and image in the sprites option or choose color. It is better to choose image as
it looks pretty good.
I have some images which we can apply to the background in
sprites folder in Assets.
To add an image first we need to change image properties by
selecting image and on inspector tab under texture type choose Sprite (2D and
UI) and click apply. Do this for all images if you have any.
Now select Background from Hierarchy and drag and drop image in sprite folder to Source Image option in Inspector tab.
Now the Background is a layer and we can set in in front or
back to other images by setting Order in
Layer in Sprites Rendered. As background needs to be lowest so we set it to
-3.
Now create another three 2D sprite squares and name them as
clouds, tree, mountain and ground or you can duplicate thrice background and
change names and images of clouds, flowers and ground.
Now select the tree and scale it with rect tool as you need
the size.
Duplicate tree 4-5 times and add place in different
locations from Move tool.
Set Order in Layer in
Sprites Rendered for clouds and mountain to -2, ground to 0 and trees to -1 for
all 3 images.
Let’s now create same way 2 images of Asteroid and Dino and
set order layer to 0 for both.
You can see that dino legs are apart coz we need to set
animation for player.
In this scene there are 3 interactables Dino – player, Asteroid
– Destroyer and Ground – move space.
Other images are stationary so we do not need then working.
For these 3 interactables to work we need colliders and rigid body which we will see in next session.
No comments:
Post a Comment