[No coding] Using Components

Information
Step 1
In this lesson, we will try out various components to see what it does on an object!
Ezgif.com video to gif %288%29
Step 2
Create a new scene or stay on the current scene/project if you have Unity opened.
Temp1544606367
Step 3
In the Hierarchy create a plane, in the project panel create a black material and click n drag onto the plane.
Temp1544606464
Step 4
Create a cube slightly above the plane.
Temp1544606526
Step 5
Select the Main Camera, Look at the camera view and make sure the cube is visible.
Temp1544606681
Step 6
Your Camera Preview is actually your Game mode view
Step 7
Click play and you'll see that nothing happens yet.
Information
Step 8
Optional: Turn off 3D Icons and Grid lines in Gizmo if it's too hard to see the objects.
Temp1544606989
Step 9
Select the cube in the Hierarchy/Scene, in the inspector, add a component called Rigidbody.
Temp1544607085
Step 10
Now try clicking play, the cube will then have gravity. Next, stay in play mode, click on Scene, drag the cube up!
Step 11
Create a Sphere and put it next to the cube. Give that a rigidbody also, and disable both their gravities.
Temp1544607628 Temp1544607670
Check Your Work
Step 12
Hit play and try to move the sphere into the cube and let got of the mouse.

Because there is no gravity, both objects move freely in space! Just like in outer space!

Step 13
This time enable Kinematic for the Cube. Click play, try "slowly" moving the sphere into the cube.
Temp1544607939

Kinematic objects are frozen in place and does not move but they do have collision.

Step 14
Disable all gravity and Kinematic on both object's Rigidbodies. And then add a Configureable Joint on the Sphere.
Temp1544608306
Step 15
There is a lot of settings here, don't worry we'll only use 4 of them. Click and drag the cube onto the connected Body.
Step 16
Click the triangle arrows on X,Y,Z drive to open them on this joint component of the sphere.
Temp1544609119
Step 17
With X,Y,Z Drive opened on this panel. Set all Position Spring to the value of 1.
Temp1544609224
Check Your Work
Step 18
Now hit play and go to the scene mode, Try clicking and dragging the sphere away from the cube.

Just imagine them being connected by an invisible spring!

Step 19
Let's move onto a special render called the Trail Renderer! Delete both cube and sphere objects.
Temp1544610130
Step 20
Create a new sphere and attach a Trail Renderer component to it.
Temp1544610212
Step 21
Let's hit play, go to scene view and drag the sphere to see the trail.... Uh oh, it's pink! It's missing a material!
Step 22
Create a new material in the project panel, Name it TrailMat and make it any color you want.
Temp1544610552 Temp1544610683

I decided to make mines this color

Step 23
Go back to Trail Renderer for the sphere, Click the triangle arrow where it says Materials to open it.
Step 24
Click and drag TrailMat into where it says "Element 0"
Temp1544610840
Check Your Work
Step 25
Click Play and check again if it's showing the right trail material.
Step 26
We notice that the trail is taking awhile to disappear. In the trail render, the time is in seconds. Change this to 0.3
Temp1544611227
Check Your Work
Step 27
Click play and test again to see if the trail disappears after 0.3 seconds.
Planning
Step 28
Next we want to change the end of the trail to become more pointed instead of flat
Temp1544611452
Step 29
To do this, change the width with this curve. Right click at the end and then add key, then drag it down.
Check Your Work
Step 30
Hit play and test your trail!
Challenge
Step 31
Shaders Challenge: Try changing the current material to just a lit up color instead of a metallic blue.
Temp1544611835
Step 32
Next we'll work on Constant force and Prefabs. On the same sphere, add a new component: "Constant Force"
Temp1544611938
Step 33
Make sure Gravity and Kinematic is Unchecked. And give this a constant force of 50 for x.
Temp1544612066
Check Your Work
Step 34
Click play and see which direction this will go.
Information
Step 35
My camera might be a different position from yours. I need this to fly forward. If backward is x:50, forward is x:-50
Temp1544612275
Check Your Work
Step 36
Make sure that the sphere is flying forward from your camera for the next steps of this lesson.
Step 37
Now that we have that working, we need more copies of it. We do this by saving "prefabs".

To save a prefab, click and drag an object from the Hierarchy to the Project. This will save a prefab with all the settings you've done on it.

Check Your Work
Step 38
The fun part: Click play, and click & drag this prefab into the scene!
Challenge
Step 39
Give these spheres something to hit with!

Hint on creating multiple cubes: Create one, copy it, paste it. Move it over, copy both, past both, move it, and repeat.

Step 40
Lastly we'll try colliders. The current collider of the sphere is 0.5, let's try to increase this.
Temp1544613096
Step 41
Reminder: If you change an object in the scene, only that object is changed and not the prefab.

So whatever changes you made, you have to overwrite the prefab by clicking and dragging into it.

Check Your Work
Step 42
Let's try launching just a "few" spheres this time.
Step 43
You are finished with this lesson! Click submit and go to the Challenges lesson!
[No coding] Using Components Info

Account

MVCode Clubs

Created By

Nepgear tina (instructor)

Course:

[No coding] Unity Basics

Access Level

public

For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach