Exercise 1: Basics of Unity - VapaaLassi/TAMKUnity2024 GitHub Wiki
First off, Create a new 3D project in Unity.
The first goal is to create a scene that looks somewhat like the picture above.
Things to keep in mind:
- All the objects in the scene exist and are about the same size and position as the picture
- The camera angle is pretty much the same as in the picture, it can be a bit closer or farther back, but you should be able to see everything.
- The light comes from the right side
- There is a floor that the shadows can be casted on, it can be any size. As long as all the objects are on top of it.
- The one cube in the foreground is in the air, not touching the ground.
- The whole scene can be constructed without changing any other components than the Transform, feel free to ignore any others.
When you are done, press play. Then go to the game view tab and you’ll see if the camera position is correct.
Tip: Any changes you make while in play mode are temporary. There will be many many times where something you worked on for half an hour will just instantly disappear. Might be worth it to go to the options (It's under Edit -> Preferences
in the top menu.) to add a color tint to the editor while in play mode to save a lot of unnecessary repeated work.
When you are done with the placement of all the objects, you can move on to the next part.
-
Add a Rigidbody to the floating cube. (remember to go back to the scene view, so you can see which object is selected)
- You can also start learning good habit already and start naming the objects in a reasonable way.
-
When you press play, the cube should drop down.
-
Let’s make it a bit more interesting and move the cube back and up so it’s above the big sphere in the back. Something like this:
-
Now press play again. Physics!
Tip: You might need to scroll down in the right side of the inspector tab to find the button to add new components if there is already many components on the object.
-
So, to introduce some audio to this course, create an empty GameObject add an AudioSource to it. Then add any music audio file to it.
- You can drag and drop audio files into the Project tab
-
Press play again. You should now hear music.
-
Then to test the how 3D sound works, find the floating cube object and add an AudioSource to it. Then add any audio file that you can hear over the music to the audio source and make sure to tick the "Loop"-box. Also, find the Spatial Blend setting in the audio source and turn it all the way to the 3D end.
-
Now, let’s stay in the play mode and do something stupid. While the game is still running, change over to the scene tab. Find the floor/plane in the scene and turn off the collider, by clicking the little toggle box in the collider component.
-
Instantly something should happen. First, the box should drop down through the floor. Also, if you were listening closely, the sound should fade out and disappear. Why does that happen?
- EXTRA TASK 1: To really learn how nothing that happens in play mode is permanent, press play, make sure the play button is pressed down and switch over to the scene tab. Then, mess up the scene as much as possible. Add new objects, random components, delete existing ones, make something 10 times bigger, move things around, duplicate something 15 times, anything you can think of. Then, when you are happy with the mess you’ve made, click the play button and everything should go back to exactly how they were.