Week 1: Programming a car on a road to avoid obstacles, familiarizing with Unity editor and workflow, and scripting basics in C#.
So far, this tutorial has been pretty impressively organized with the mass of material provided. Thought it'd be neat to leave some note-worthy point-form notes from this tutorial! Here's to organizing some of it in my brain (and computer)!
Unit 1
On this week's Unit 1 menu:
Essential content
1.1 Start your 3D Engines
Some shortcuts in Scene view:
Hold right-click + WASD = fly/rotate
F = frame/focus on selected object + scroll wheel = zoom in/out + hold scroll wheel = pan + hold alt+left-click = rotate around object perfectly
Ctrl + Z = undo most recent action(s)
Hold Ctrl/Cmd + Move with Mouse = move object by whole units
QWERTY = Toolbar Tools: Hand / Move / Rotate / Scale / Rect / Move, Rotate or Scale objects respectively
Customizing and Saving Custom Unity Editor layouts
1.2 Pedal to the Metal
Adding Components to Objects
Project > Assets > Folder organization
Script components - creating a script to control the vehicle's movement using Visual Studio (one of many editors including Atom, Sublime, or even a basic Text Editor)
classes = start with capital letters (e.g. PlayerController, MonoBehaviour, Transform = class vs. transform = access the transform component of an object)
comments = for people to read and understand what's in the code (being with //)
methods/functions = pieces of info for the computer to run a task
semicolons (;) at the end of a method determine the end of a method
RigidBody components - adding physics to objects and adjusting parameters including Mass (kg) and Gravity
Ctrl + D = duplicate object(s)
IDE (Integrated Development Environment) = a script-editing tool; "a piece of computer software that provides tools and facilities to make it easier to develop other pieces of software", e.g. when typing in Visual Studio, the IDE will suggest options/methods for your code
So, our vehicle drives forward automatically
and has weight (as do the obstacles it drives into).
1.3 Speed Chase
Declaring Variables = piece of info that can vary/change in the format of: [access modifier] [data type] [variable name] = [variable value]
Tip: initialize new variable (e.g. public float speed = 5.0f) (stores values)
Can store different data types (e.g. game objects)
new Variables inside a method are variables just in that method/line of code Tip: it's not great to have hard-coded values - it's better to create/declare a variable for these values
Access modifiers
private (can only be accessed from within that class)
public (can be seen and used outside of its class, e.g. in Unity Editor))
Now, our camera follows the vehicle as it moves forward in a direction. However, it looks like it's attached underneath the vehicle.
Offsetting with a variable to adjust the camera position did the trick!
3. Edit > Preferences > Colors > Playmode tint (for more clear indication when in Playmode)
The rest of the Editor Interface now changes green when in Playmode (even on Pause, as Playmode is still active).
1.4 Step into the Driver's Seat
Variable naming convention = start with lowercase letters for access modifiers, data types, and variable names (variables vs. Upper case for class, methods...)
Edit > Project Settings > Input (different keys/inputs assigned to various Unity aspects. e.g. Horizontal/Vertical axes)
Cleaning Up Script
Cleaning Up Hierarchy with Empty Game Objects
The vehicle can now move sideways!
Now our vehicle actually rotates sideways/around obstacles like a normal vehicle would!
These movements here are actually controlled by key inputs (left/A and right/D keys) to control the movement of our vehicle - it's actually interactive!
So I think we have a working car that drives with player input, and has a camera that follows behind it! Onto the Bonus features!
Comments