Unity Version: 2019.3
-
Make sure that the teachers have Unity and Visual Studio involved.
- Walk through it in case they do not.
- Explain Unity Hub as well
-
Explain UI and opening a new project
- Explain different windows
- Go over the Director/Movie set analogy
- Scene View: Director walking around a set
- Game View: Final Cut of the movie/show
- Heirarchy: Items in your set
- Project Assets: Props that may or may not be in the set
- Explain Play Button and how it swaps to Game View
- Floor and 3D Shapes
- Lighting and Camera
- Navigating through scene view
- Add a floor plane. Scale it larger. Go over transform tools and effects of them.
- Add a sphere above the plane - show that it does not fall
- Explain objects do not have any type physics by default
- Give sphere a color. Explain materials briefly.
- Create an empty object. Explain 3D coordinates and components.
- Move camera and show how it affects Game View. Finally move it above your scene looking at the ball from a downward ish angle. Try to face towards the positive z axis - as this will pretty much be required down the line when we add controls. You might need to tweek this position and rotation later as it will be crucial when we hook our camera up to follow our ball.
- Rigidbodies
- Add Rigidbody to sphere.
- Add other objects under it, at angles, etc so it can interact with them.
- Tilt the plane temporarily so we can see the ball interact with it
- Show that objects can fall forever.
- Play around with default rigidbody settings
- Our first coding script
- Controls for moving our ball
- Show off what it means to add a script to a GameObject.
- Explain Start() and Update() functions briefly.
- Use Debug.Log to show off the start function vs the update function. Also explain that this is how we can print messages to the console window for debugging purposes.
- Create if statements for all the keyboard functions (but don't fill out the any executable code inside)
- Explain this line of code briefly, but explain that it's not crucial to understand the syntax or symantics of this line of code because they're just starting out.
GetComponent<Rigidbody>().AddForce(Vector3.up)
- Add the public floats for jumpStrength and moveStrength.
- Talk briefly about how public variables can be set in the inspector. And maybe just a bit about how the vector inside AddForce chooses the direction, and our variable chooses the strength in that direction (magnitude).
- Use it in the AddForce Method (see code below).
- Tell them to experiment with the values in the inspector.
public float jumpStrength;
public float moveStrength;
void Update()
{
if (Input.GetKeyDown("space"))
{
GetComponent<Rigidbody>().AddForce(Vector3.up * jumpStrength);
}
if (Input.GetKey("w"))
{
GetComponent<Rigidbody>().AddForce(Vector3.forward * moveStrength);
}
if (Input.GetKey("a"))
{
GetComponent<Rigidbody>().AddForce(Vector3.left * moveStrength);
}
if (Input.GetKey("s"))
{
GetComponent<Rigidbody>().AddForce(Vector3.back * moveStrength);
}
if (Input.GetKey("d"))
{
GetComponent<Rigidbody>().AddForce(Vector3.right * moveStrength);
}
}
- Checking Rigidbody collisions
- Add a cube.
- Try to collide with Cube. Note what happens.
- Add Rigid body to cube. What happens?
- Now try to collide with cube.
- Duplicate cube and make tower or pyramid that we can knock down.
- Play with rigidbody parameters when impacting the cubes.
- Vector and Offset
- Transforms
- More on Public Variables
- Create new script for CameraController and attatch it to the Camera.
- Add public variables for ball and offset. Declare the GameObject ball and explain that all items inside Unity heirarchy are GameObjects. And that a GameObject consists of a transform and components. Go over transforms and show off components again. Declare an empty object as example.
- Show off that we can drag items into public variables. Drag sphere/player ball into reference.
- Add code for Update function to set ball to camera.
transform.position = ball.transform.position;
Explain that we are setting the position of whatever this script is attatched to - to the position of the ball. Show off in play mode. - Show off the Start function. Use Debug.Log()
- Update the line of code to put an offset in. Set the offset in the Start Function.
public class CameraController : MonoBehaviour
{
public GameObject ball;
private Vector3 offset;
// Start is called before the first frame update
void Start()
{
offset = transform.position;
}
// Update is called once per frame
void Update()
{
transform.position = ball.transform.position + offset;
}
}
THAT'S IT! HAVE THEM CUSTOMIZE TO THEIR HEARTS CONTENT :)) ADD LOTS OF BLOCKS FOR FUN AND DESTRUCTION.
Show off more customizable materials if time. And maybe the other 3D shapes etc.
If lots of extra time, you can start making an obstacle course.