ROLL-A-BALL TUTORIAL #2

#Creating stage

At first, we must create materials for the composing stage. 
Ex. ground and walls and so on.

#1. Creating groud
At first, we create the ground. See below for creating "Game Object" to have function "Panel" in this "Scene".

1.	Click "Create" in "Hierarchy"
2.	Select "Panel" in "3D Object".
![図1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/4ca524f3-80d1-6d4a-f77d-45d2426f2981.png)


>About "GameObject ・・・ "In “Unity”, we call all putting materials in “Scene” by “Game Object”. “Game Object” is appeared 3D meshes, lights (stage lighting), physical objects, transparent sounds, and triggers. Unity manages all materials, assigns and controls scripts optionally.

#2. Setting ground

We adjust the ground to size. There are two options. Option 1 is setting Panels. Option 2 is stretching. Today choose a setting, it’s no reason.

1.	Select “Panel” in the “Hierarchy” view, and select the right-click and “Duplicate”.
2.	Select the newly created “Panel” position, and change the “Move Object” mode in control mode at the left top panel.
3.	Adjust a “Panel” position by operating an appeared arrow.
 ![図2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/f29d8e5e-fd8a-fe3e-ec36-b46818ce7783.png)

We will make ground by 4 “Panel”s.
Then, we should change “Panel” names. We change “Panel” names to “Ground1”, “Ground2”, “Ground3”, and “Ground4” as the object names. We can change object name at the name in the top of Inspector View
![図3.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/7d95704d-80b4-ec19-6e80-87a54ddd2b78.png)

 
#3. Adjusting position
At last, we should adjust the position numerally. When adjusting the position, we would find that change selection and each time change the parameter in the inspector view on the right of the editor.
This inspector view shows a component detail to compose Game Object is selected. There are components as “icon”, “checkbox for enabling or disable”, “component name”, “option” from the left side to the right side. There is “help” on the left side of “option”, and we can see help documents.

#4. Setting up 4 Panels
Actually. We will adjust coordinates. The transform component manages coordinates. “Position” manage coordinates of the object, “Rotation” manage spin of an object, and “Scale” manage the size of the object. Today, we adjust the position, see below.
 ![図4.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/1ed82739-e864-38b6-c81f-7592a7157592.png)

●	Ground1(x:5, y:0, z:-5), 
●	Ground2(x:5, y:0, z:5), 
●	Ground3(x:-5, y:0, z:-5), 
●	Ground4(x:-5, y:0, z:5)
 ![図5.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/3070ce39-25ee-921a-51bd-7b3056315179.png)

#5. Painting ground color
We will set the color on the floor.
2 ways set the color on “Model”. 1st way is setting texture, and 2nd way is setting the color of all models. “Material” file manage material of these color and reflection.

1.	Click the “Create” button on Project Browser.
2.	Select “Material” in the list.
3.	Change the name to “GroundMaterial”.
 ![図6.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/fef3b586-f1fd-90d8-4ebd-9f8efb6cadd7.png)

##5-1. Setting color at “Material”
Next, we set the color at “Material”.
1.	Select “GroundMaterial” that created before this.
2.	Select “O” of the left side, and select “Default Checker”.
 ![図7.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/a5824dda-cb3c-7ffa-9a2f-38d4572e43c6.png)

##5-2. Setting “Material” on “Ground”
Next, we will paint color on Ground that used Material detail.
1.	Drag & drop “Ground” on Ground(1-4) in Hierarchy view
 
#6. Creating a wall
We will make a stage that have 4 walls all around. There are walls all around, function to the ball cannot go outside. 
Then, shall we create walls?
1.	Click the “Create” button in the “Hierarchy” view.
2.	Create “Cube” from “3D Object > Cube”.
3.	Rename created “Cure” to “Wall”.
 ![図8.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/f2f44f48-011f-ce6a-3950-6dbbc36e3736.png)

##6-1 . Setting wall color

We will change the wall color.
1.	Click the “Create” button in the “Project” browser.
2.	Select “Material”.
3.	Rename “WallMaterial”.
4.	Select “WallMaterial” and set “albedo” to color like red.
5.	Drag & drop “WallMaterial” onto the “Wall” object.
 ![図9.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/07c39597-04fd-1cfe-f8fa-25870b032279.png)

##6-2. Putting wall
Next, Use a way of stretch, to change wall size to create.
When stretching, select the scale model from the top left panel, and select the object, and drag the block in the direction you want to stretch.
Next, select the created Cube in Move mode, and hold down “V” to move.  By moving while holding down V, it moves as to suck at the apex of another model, so you can easily adjust it.
We adjust to the inspector's view of completeness. “Panel” size corresponds to “Cube”'s 10x10, so change the below size.
Position(x:-0.5, 0.5, -9.5)
Scale(x:19, y:1, z:1)
 ![図10.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/77ae2ae8-33ad-ebab-5792-4220d62cf375.png)

Put on the opposite. Duplicate the created “Cube”, and put on the opposite.
Position(x:0.5, 0.5, 9.5)
Scale(x:19, y:1, z:1)
 ![図11.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/9e8d5ce7-4c4f-f2a0-0ea4-883d3e71f9aa.png)

##6-3. Rotating object
We have two ideas to put the walls on both sides. 1st idea is to "stretched Cube stick" by “rotate 90 degrees”. 2nd idea is creating a stick that stretches to a different direction ((x: 1, y: 1, z: 19).
We can use the way “rotate 90 degrees”. Because explain the way of rotation.
To rotate, select rotation mode, and drag the displayed outer frame. Operating while pressing Ctrl (Command) and so rotates by 45 degrees each time.
But set on Inspector view. First, duplicate one of the “Cube” and create “Cube 3”. Next, set below for “Cube3”’s rotation.
Position(x:-9.5, y:0.5, z:0.5)
Rotation(x:0, y:90, z:0)
 ![図12.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/40371361-a728-26f4-82ef-ad5169a78477.png)

Duplicate “Cube3”, and create “Cube4”. Adjust the following position.
Position(x:9.5, y:0.5, z:-0.5)
 ![図13.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/c1eb28ad-af9e-c983-864e-7f54174fc2c6.png)

#7. Rearrange object
It becomes troublesome to clutter an object and a scene in the project. So, we use an empty object and organize the objects.
##7-1. Setting Material
Make a “Material” folder for a Materials list, and save it in this folder.
1.	Click “Create” on the Project browser.
2.	Select Folder.
3.	Change the Folder name to "Material".
4.	Select "GroundMaterial" and "WallMaterial". Drag & drop to the "Material" folder.
##7-2. Create a blank "Stage" object
Next, sort out objects in the "Hierarchy" view. Create a blank "Stage" object.
1.	Click the "Create" button in the "Hierarchy" view.
2.	Select "Create empty".
3.	Change object name to "Stage".
4.	Select the list of “Wall” and “Ground” last step created in the “Hierarchy” view. Drag & drop to “Stage” object.
![図14.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/6fdd42ab-e738-ee11-e264-f87b2e3be203.png)

 
##7-3. Putting on “Stage” as a static object
In the last step, the stage object is not a dynamic object, then putting the static object. Because performance and visual will be improved.
1.	Select the "Stage" object in "Hierarchy" view.
2.	Check the "Static" button on the "Stage" object in the "Inspector" view.
3.	Show "Do you want to enable the static flags for all the child objects as well?" and we select "Yes Change Children".
  
![図15.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/512084/0c534b8d-7ca0-21e3-8fd4-0129d7e67dd1.png)