revision

advertisement
#pragma strict
function Update () {
transform.Rotate(0,5 * Time.deltaTime,0);
Explaination : Game object will rotate 5 degrees per second along the y axis
#pragma strict
function Update () {
transform.Translate(5, 0, 0); }
Explanation: Game object will move along the X axis by 5 every frame
#pragma strict
function Update () {
transform.Translate(5* Time.deltaTime, 0, 0); }
Explanation: Game object will move along the X axis by 5 every second
function Update () {
transform.LookAt(targetGameObject); }
Explanation: Rotates the transform so the forward vector points at targets current
position
private var myDegrees = 100;
private var rota4onState = 1;
function Update () {
if (rota4onState == 1) {
transform.Rotate(0, myDegrees * Time.deltaTime, 0); } }
func4on OnMouseDown () {
if (rota4onState == 1) {
rota4onState = 0; }
else if (rota4onState == 0)
{ rota4onState = 1; }
}
Explanation: If rotationstate==1, rotate game object 100 degrees per second. When user
presses mouse button and state is =1 do nothing, if state is =0 execute transform.rotate
function
var dist = Vector3.Distance(transform.posi4on, other.posi4on);
Explanation: Returns distance from a to b
public var rocket: GameObject;
function Update () {
if(Input.GetKeyDown (KeyCode.Z) {
var rocketInstance: GameObject;
rocketInstance = Instantiate(rocket, transform.position, transform.rotation);
rocketInstance.rigidbody.AddForce(transform.forward * 5000);
Destroy(rocketInstance,1); }
}
Explanation: instantiate is used to clone objects, in this case when the user presses the Z
key the cloned rockets will be positioned and rotated and then force is added to fire the
rockets forward by a certain amount(5000).
Lighting
Don't Put Sweets Away
Directional- a light placed infinitely far away, it affects everything in the scene
Point - shines equally in all directions, affects everything within range
Spot- shines everywhere within a cone defined by spot angle and range.
Area- Shines in all directions to one side of a rectangular area of a plane.
Unity Physics
Speed
 Can be thought of as the rate at which an object covers distance
Velocity
 Speed and direction of an object
Acceleration
 Change in speed over time
Force
 Influence that cause an object to undergo change, either in its movement/ direction
Torque
 The turning force of an object
Friction
 The resistance that one surface of an object encounters when moving over another
Rigid Bodies
 Physically simulated objects
 Enable game objects to act under control or the law of physics
Colliders
 Must be added alongside a rigid body to allow collisions to occur
 If two rigid bodies bump into each other, the physics engine will not have to calculate a
collision unless both objects also have a collider attached
 An invisible wireframe model/mesh that sits around the 3D object
Hinge Joint
 Groups together two rigid bodies constraining them move like they are connected by a
hinge e.g. a door
Materials & textures
Material
 The collection of properties added to a 3D object
Texture
 An image that is repeated across the surface of the 3D geometry
Material Properties
Every Animal Deserves to Smile
Emissive
 Self- illumination colour an object has
Ambient
 The colour of an object where it is in shadow. This colour is what reflects when illuminated
by ambient light rather than direct light.
Diffuse
 That essential colour that the object reveals under pure white light. It's perceived as the
colour of the object itself rather than a reflection of light.
Specular
 The colour of the light of a specular reflection = characteristic of light reflected from a shiny
surface.
Common mapping types
Planar
 The image is projected from the chosen direction, through the mesh
Box
 Planar projection of the image are put on each side of the object in a cube fashion
Cylindrical
 Image is wrapped into a cylinder and projected inward and outward onto a mesh.
Spherical
 Image is wrapped into a cylinder, then gathered at top and bottom.
3D Rendering
Shaders
 Key part of rendering and rasterisation
 A material is just one parameter a shader considers along with the effect of light etc.
Flat shading
 The colour of the polygon is calculated at the centre of the polygon by using the
normal vector
 The complete polygon surface is uniformly lighted.
Download