Thursday, August 29, 2013

Kiwinuptuo's Color Palette Tutorial

http://kiwinuptuo.deviantart.com/art/Pixel-Art-Tutorial-Colors-184802567

Notes:

  • Base: Pick based on Marc Brunet's Color Theory (http://bluefley.blogspot.com/)
  • Shadows:
    • Hue: Move away from center
    • Saturation: More Saturated
    • Value: Darker value
  • Highlights:
    • Hue: Move toward center
    • Saturation: Less saturated
    • Value: Lighter value

Wednesday, August 28, 2013

MAYA: Creating Layered Mia_Material Shaders Tutorial

http://vimeo.com/23032246

In order to use a LayeredTexture with Mia_Materials, use a SurfaceShader and manually connect the "Result" from the Mia_Material, to the "outColor" of the SurfaceShader.  Then plug the SurfaceShader into the LayeredTexture.

BAM. Layered Mia_Materials textures.

Thursday, August 22, 2013

Drawing: Art Marker Tips & Techniques

Tips:
  • When lines show up during fills, stroke the opposite direction to get rid of them.
  • Colorless Blender markers are great for erasing and blending on tracing paper.
    • can also load multiple colors on the clear nib and do strips.
    • can use plastic palette to mix colors.
    • just remember to clean off blender.
  • put acetate or plain white paper to modify bleed characteristics.
  • can use Prismacolor color pencil to correct overly darkened values.
  • Vehicles:
    • always have a ground shadow
    • find your dark areas (optional technique)
    • otherwise, render from light to dark (since there's no UNDO) aka. "Sneak Up" on the values.
    • ground colors bounce off and show in areas close by.

Wednesday, August 21, 2013

UNITY: General Unity Notes

This will be an on-going post with all the little small tidbits I've found while working with Unity.

UPDATE: Each section of the manual will now be broken into sub-categories, starting with " Creating Gameplay "

2013.SEP.11:

Robust C# language feature to prevent clashes between scripts. " Enemy.Controller1 "

Scripts in a later phase can utilize variables and functions in an earlier phase, but not vice versa.  Compile order:
  • Phase 1: Standard Assets, Pro Standard Assets, Plugins
  • Phase 2: Standard Assets/Editor, Pro Standard Assets/Editor, Plugins/Editor
  • Phase 3: All other scripts not inside a folder called Editor
  • Phase 4: All remaining scripts (example: ones inside the Editor folder)
Anything inside a folder called WebPlayerTemplates will not be compiled.

Event Functions:
Update events, Initialization events, GUI events, Physics events:
Awake(), Start(), Update(), FixedUpdate(), LateUpdate(), OnGUI(), etc.

"Transform.Find" Function:
This can be useful when an object has a child that can be added or removed during gameplay. A weapon that can be picked up and put down is one example.

Direct Component Access:
If a public variable of a "Component Type" is declared, you can drag any GameObject that has the component attached to it. This will access the component directly, rather than the GameObject itself.

Unity uses industry standard "Substance" shaders.  Procedural shaders take a much smaller storage footprint than a bitmap image.

Unity Built-In Shaders Guide
Extensive guide regarding Unity's built-in shader models.

Alpha Maps Guide
Guide to creating Alpha maps in photoshop.

Detail Meshes:
Use for any static terrain decorations that are not Trees or Grass.

Grass:
Same as Trees, but doesn't require a mesh.  Just need a texture.

Create:
  • Create > GameObject > Create Other > Wind Zone 
Use Unity's built in TREE BUILDER utility.  
  • add Branch Group
  • tweak
  • add Leaf Group
  • tweak
  • import "Tree Creator" asset package
  • add Materials
    • Nature > Tree Creator Bark
    • Nature > Tree Creator Leaves
  • select Nodes in NodeTree
    • apply Bark shader
    • apply Trees shader

Textures:
Use the "RGBS" format: Store "Specular" information in the Alpha channel, and save with TIFF.  Doesn't work with PNGs.

In order to paint normal map "Splat maps", you have to make sure the Terrain has a normal-map-capable shader applied to it.

If you have 2 or more Terrain textures applied, you can begin to 'Blend' them together using a method similar to Photoshop layer masks.

Using Camera Depth, a variety of effects can be done. One example would be to have Depth 0 render the environment, then Depth 2 render the player's UI and the FPS weapon. That way the UI and weapon is always drawn on top, regardless of penetration etc between gun object and environment.

Prefabs:
Prefabs and Assets are different.  Assets have certain limitations that Prefabs do not when working in the project.

You can assign an icon to an object by clicking on the icon next to the name in the Inspector, then selecting one of the default icons, or a custom icon of choice.  Name of object will be displayed as well.

Object Labels:
Items in the Project view can be labeled by clicking the little blue "..." in the object's preview.  Custom labels can be created by just typing in a name.

Component View:
There are two main types of Properties: Values and References.

2013.SEP.03:

Unity Effects!

Easily put a trail on bullets this way.


2013.SEP.0C.D: Unity Beginner Scripting (Unity Official)

" Classes "
Use classes to to store and organize your information, and how to create constructors to work with your class.

Analogy:

  • Classes : Factory
  • Functions : Machines
  • Variables : Boxes
Example scripts: (basic movement, inventory, and shooting):

Name of classes should be the same as the script.  Avoid changing it unless absolutely necessary.  A class is a container for variables and functions, an organizational tool for "object oriented programming".  The idea is to split the script into multiple scripts, each handling one task.

A PlayerControl script that has all "movement", "inventory", and "shooting" all in the same script should be spit into individual scripts.  Each script handling a task makes it easier to read and more efficient to write.

Sub-Classes can be created within the script/class, and can be instantiated within the same script. 

Example:

//declare sub-class
public class Stuff
{
    public int bullets;
    public int grenades;
    public int rockets;
}
//creating an Instance (an object) of the "Stuff" class
public Stuff myStuff = new Stuff();

Data type: name of the class,  Name: "myStuff",  new,  end with name of class again.  Using " () " at the end means that a "constructor" is being used.

A " Constructor " is a function that can give default values to the variables in your class.

Example 01:
// Constructor, this goes inside sub-class
public Stuff ()
{
    bullets = 1;
    grenades = 1;
    rockets = 1;
}

Example 02:
// Constructor example 2, using parameters
public Stuff (int bul, int gre, int roc)
{
     bullets = bul;
     grenades = gre;
     rockets = roc;
}

Then instantiate using:
" public Stuff myStuff = new Stuff(50,5,5); "
This will instantiate a "new" instance of "Stuff", a "Stuff" type variable, with 50 bullets, 5 grenades, and 5 rockets.

Notes about Constructors:
  • name of the Constructor is always the name of the Class
  • Constructors never have a return type, not even "void"
  • a Class can have multiple different Constructors, but only one is called when an object is initialized
  • different instances of the Constructor will be used depending on their parameters

" Instantiate " 

Create clones of Prefabs during run time.

One example is firing a Rocket from a bazooka.  Each Rocket would have to be instantiated into the game world so that it could be fired.

Example:
(inside instantiate script class)
public Rigidbody rocketPrefab;
public Transform barrelEnd;

void Update()
{
   if(Input.GetButtonDown ("Fire1"))
   {
      Instantiate(rocketPrefab);
   }
}

Drag and drop Prefab item into the public field.  Unfortunately, this setup will only instantiate the object at origin (0,0,0).  Instead, create an empty GameObject and position it at the barrel.  Drag this object into the Transform variable field "barrelEnd".  Then use:

" Instantiate (Prefab to clone, Position, Rotation to use); ", which would be:

" Instantiate ( rocketPrefab, barrelEnd.position, barrelEnd.rotation ); "

Rocket should be created at barrel tip, but falls down. To remedy this, define a new "Rigidbody" types variable called "rocketInstance", then define rocket instance:

Rigidbody rocketInstance;
rocketInstance = Instantiate(rocketPrefab, barrleEnd.position, barrelEnd.rotation) as Rigidbody;

At this point, you can use anything in the Rigidbody class, such as:

Rigidbody.AddForce (Transform.forward * amount);
or
" rocketInstance.Addforce (barrelEnd.forward * 5000); "

All is well, except that these objects need to be destroyed or else they'll eat up memory.  Create a new script that destroys the object over time.

script:
public class RocketDestruction : MonoBehavior
{
   void Start ()
   {
      Destroy (gameObject, 1.5f);
   }
}


2013.SEP.02.C: Unity Beginner Scripting (Unity Official)

" Delta Time "
Can be used in games to smooth and interpret values.  "Delta" means difference, and Time.DeltaTime is the time between each Update() or FixedUpdate().  Can be used to smooth out movement inputs, or other values.  It changes movement values to "per second" rather than "per frame".

Use: Multiply variable by " Time.DeltaTime "



" GetComponent "
Use this function to address properties of other scripts or components.

A script in Unity is considered a custom component.  "GetComponent" is used to modify other scripts on the same GameObject, or even other objects.  The function is very expensive, and should only be called on the "Awake()" function or "Start()" function.

Use:
" GetComponent(); "
" otherGameObject.GetComponent(); " (after declaring a proper variable)


" OnMouseDown "
Can detect clicks on Colliders or GUI Text elements.

Use:
void OnMouseDown()
{
    (Do something) ;
}

example things that can go between the curlies:

  • rigidbody.AddForce( transform.forward * 500 );
  • rigidbody.useGravity = true; 

2013.SEP.02.B: Unity Beginner Scripting (Unity Official)

" Destroy "
  • Use:
    • " Destroy(GameObject/Component, optional delay); "
  • by default, this destroys the current game object, along with its attached script, but a public GameObject variable "other" can be created, so another object can be referenced within Unity.
  • "GetComponent" function
    • Use: " Destroy (GetComponent(); "
  • a timed delay can be employed as the optional 2nd argument
    • Use: " Destroy(gameObject, 3f); " (floats only)
" GetButton and GetKey "

Part of Unity's "Input" Class.  Buttons return a Boolean.
  • when nothing is pressed:
    • GetButtonDown: FALSE
    • GetButton: FALSE
    • GetButtonUp: FALSE
  • when button is pressed:
    • GetButtonDown: TRUE
    • GetButton: TRUE
    • GetButtonUp: FALSE
  • when button is released:
    • GetButtonDown: FALSE
    • GetButton: FALSE
    • GetButtonUp: TRUE
It's recommended to use "GetButton" over "GetKey" because players can configure them before game launches.  You can configure buttons via "Input Manager" under the Edit menu.

Examples:
  • GetButton Syntax: " bool var = Input.GetButton("string"); "
  • GetKey Syntax: " bool var = Input.GetKey(Keycode.key); "

" GetAxis "

Unlike GetButton and GetKey, "GetAxis" returns a float value between -1 and 1.  Axis are setup in the Input Manager under the Edit menu.  Also unlike a button which only is a positive button value, GetAxis also needs a negative button value.  Other settings required for setting up an Axis:
  • Gravity:
    • speed of return to zero. Higher values snap, lower values float.
  • Sensitivity:
    • opposite of Gravity, speed of getting to 1 or -1. Higher value the more responsive, lower the value the more smooth.
  • Dead:
    • if using a joystick, controls the deadzone.
  • Snap:
    • returns to zero if both positive and negative buttons are held (for buttons)
To use: 
  • " float h = Input.GetAxis("Horizontal"); "
  • " float v = Input.GetAxis("Vertical"); "
" Input.GetAxisRaw "
Only returns whole values, useful for 2D that requires precise controls rather than smooth values (JWX NOTE: For menu navigations, etc).

2013.SEP.02:

" Translate and Rotate "
  • transform.Translate(new Vector3(0,0,1));
    • takes new vector3
    • inside the Update();, it'll be updated by every frame
    • multiplying by "Time.DeltaTime" will convert this from a frame by frame operation to a X-per-frame operation.
    • can use shortcuts, Vector3.forward, Vector3.up, etc.
    • multiply "moveSpeed" variable 
    • only use when RigidBody "Is Kinematic"
" Look At "
  • can be used to point and object's FORWARD vector to another object's transform location
  • " transform.LookAt(target); "
  • add public Transform type variable called "target"
  • drag gameObject from Hierarchy into the "target" field in Unity UI
" Lerping "

Vector3.Lerp:
  • used to smooth a transition between two Vector3 values
  • short for "Linear Interpolate"
  • use: " Vector3.Lerp(from Vector3. to Vector3. time float) "
    • Lerp(from, to, time);
      • Lerp(transform.position, newPosition, Time.DeltaTime);
        • can multiply Time.DeltaTime with a float
Mathf.Lerp:
  • used to smooth out two float values
  • use " Mathf.Lerp(from float, to float, time float) "
  • encapsulate in function that runs every frame (Update(), etc)
Color.Lerp:
  • used for Lerping color values
  • use " Color.Lerp(from Color, to Color, time float) "
  • encapsulate in function that runs every frame (Update(), etc)
Use "void Awake () " function for defining new Lerp Variables.

2013.AUG.30:

  • "object.enabled = true" to enable objects
  • "object.enabled = false" to disable objects
  • "object.enabled = !object.enabled" to toggle
    • "!" exclamations are used to denote "not"
  • "gameObject.SetActive(true)" 
  • " Debug.Log("Active Self: " + myObject.activeSelf); "
    • returns a boolean of whether or not the object itself is active
  • " Debug.Log("Active Hierarchy: " + myObject.activeHierarchy); "
    • returns a boolean of whether or not the object Hierarchy is active
  • void Update ();
    • frame rate dependent, and frame rate fluctuates depending on load
    • for things like controllers
  • void FixedUpdate ();
    • refresh is fixed, update is consistent
    • used for things requiring physics
  • void LateUpdate();
    • follow cameras, procedural animations, gathering last known states

2013.AUG.29:

  • .ToString();
    • method used to cast a result to a string.

2013.AUG.20:

  • Negative Z-Axis is "Forward"
  • Use Mathf.Ceil to set a ceiling and cast to integer displays
  • Use Mathf.Lerp and Mathf.LerpAngle for smoothing operations

Tuesday, August 20, 2013

UNITY: Creating a Driveable Vehicle in Unity 3D (youtube)

http://www.youtube.com/watch?v=21zuMIsy2GM&feature=youtube_gdata_player

Notes:

MAYA:

  • make sure units are set to METERS so that units are 1:1 with Unity.
  • Length and Width: 5.0 units
  • Grid Lines every: 1.0 units

  • Average car is about 4m long, 1.5m wide.
  • label your body and wheels.
  • Delete History and Freeze Transformations.
  • Move model to properly sit on ground plane in Maya (keep transform)
  • export FBX (to Unity folder if you'd like)

    • mesh
    • units: meters, scale factor of 1.0
UNITY:
  • import FBX model into "ASSETS" folder.
  • enter scale factor of 1.0 under model's inspector panel.
  • turn off keyframe reduction.
  • hit APPLY to save information (important!)
  • drag icon into Unity scene.
  • FBX Export automatically creates group node, but in this case we don't need it so pull the assets out of the group node.
  • directly parent wheels under CHASSIS of car
    • chassis >
      • wheel_frontLeft
      • wheel_frontRight
      • wheel_rearLeft
      • wheel_rearRight
  • insert ground plane
  • zero out ground plane transforms (0,0,0)
  • (optional) add texture to ground plane
  • create empty GameObject and name it "WheelColliders"
  • zero out node to (0,0,0)
  • duplicate and name "FL_WheelCollider", which will be a template for the rest of the wheels.
  • Add GameObject>WheelCollider to "FL_WheelCollider"
  • Duplicate to the following structure:
    • WheelColliders>
      • FL_WheelCollider
      • FR_WheelCollider
      • RL_WheelCollider
      • RR_WheelCollider
  • line up all WheelColliders with actual wheel art assets
    • move CENTER xyz via INSPECTOR, not through the Scene View.[ !! ]
    • size using RADIUS
    • rinse + repeat for other wheels, with given information (size, position)
  • Add Rigidbody to CHASSIS of car object (top group)
    • change mass to 2000 (Unity units are metric, mass in KG)
    • interpolate set to "interpolate" (smooths out collisions)
  • Add BoxCollider to CHASSIS
    • (from different tutorial)
      • rough out the collision shape of your vehicle
  • Add CarScript to CHASSIS
    • configure front Left and Right wheels for steering (script dependent)
    • configure GEARS
      • number of gears
      • gear ratios
        • 4.31, 2.71, 1.80, 1.41, 1.13, 0.93 (basic 6 speed)
      • engine torque: 90
  • Add WheelAlignment Script to each of the wheel geometry
    • input corresponding Wheel Collider per wheel
  • Add Audio source (Car script calls for it)
BAM. Car.

Friday, August 16, 2013

UNITY: 3D-Motive C# Vol1 Notes

Notes: 

04: Creating Hello World Application
  • - print ("hello world");   prints "hello world" to console
  • - every script has to be attached to a game object to run
  • - USE THIS INSTEAD OF PRINT COMMAND:
    • Debug.Log("hello world");
05: Variables
  • are most important in programming
  • storing information for health, ammo, money etc.
  • the way computers remember data
  • "public" variables show up in the inspector, and also can be accessed by other scripts.
06: Writing Expressions with Variables
  • use "instantiate" for shooting objects
  • variable = variable -1;  // equivalent to decrement --
07: Enumerations
  • enumerations are lists of things
  • "enum" instead of "int", "float", etc
    • public enum Weapons {Pistol=0, Rifle=1, ChainGun=2, Plasma=3};
    • public Weapons WeaponWeAreCarrying;
  • inspector only shows variables, not enumerations
  • once "Weapons" is turned into a variable, it shows up as the variable name and appears in the inspector as a LIST.
08: Constants
  • consider constants (const) as shortcuts.
  • cannot change over time or be manipulated (just like Arduino CONST)
  • label constants in UPPER_CASE, to delineate difference between it and variables.
09: Conditional Statements and IF
  • for "out of ammo" scenarios 

10: For Loop
  • weapon modes (shotgun vs handgun)
  • for doing similar repetitive tasks
    • example:
    • for (int = i; i < 3; i++){
      • does something
    • }
  • "i" is very popular to use because it stands for "iterator"
11: While Loop
  • can be used to dump all ammo available
    • example:
    • while(ammo > 0){
      • does something
    • }
12: Functions Introduction
  • void = return data type for things that don't return anything
  • encapsulated set of instructions
13: Events Introduction
14: Function with Arguments and Returns
  • Create a weaponFire function instead of calling the code directly.
    • EXAMPLE in "PlayerControl" of Project
  • Functions can have a string output in it as a return so it can be dumped to Debug.Log();
  • Using functions can save an enormous amount of work
15: Classes Introduction
  • a class is a way to organize a collective of all sorts of behaviors
  • can contain variables, functions, etc.
  • Usually, classes are contained in one script each
16: Rotating Objects with the Transform Class
  • put instructions under "Update()" because it's redrawn every frame
    • allows for illusion of 'continuous motion'
  • Check Unity reference manual routinely to see what functions inside classes do
  • " Time.deltaTime " is equivalent to "per second"
    • tranform.Rotate (0, 90 * Time.deltaTime, 0, Space.Self);
      • calls the transform class function "Rotate", and rotates 90 degrees per second.
17:  Unity Class Documentation (navigating the site)
18: Derived Classes Introduction
  • not used ALL the time, but can be handy if objects share behavioral functionality.
19: Extending a Class
  • useful as a class modifier
    • Example: "Enemy" and "SuperEnemy" modifier
  • change from:
    • public class SuperEnemy : MonoBehaviour {
  • change to:
    • public class SuperEnemy : Enemy {
  • instructions are inherited from "Enemy" class, along with the "SuperEnemy" instructions
  • extends functionality
20: MonoBehaviour
  • by default, all Unity scripts derive from "MonoBehaviour"
  • Javascript automatically derives from MonoBehavior, but C# and Boo you have to explicitly derive from MonoBehaviour
  • explore MonoBehaviour


Tuesday, August 13, 2013

DRAWING: ProkoTV: Gesture Drawing

http://www.youtube.com/watch?v=74HR59yFZ7Y

Gesture Drawing Important Concepts:
- The Longest Axis: looking at a form's gesture, look to this first
- CSI: Simplified, look for and use only C-curve, S-curve, and straight line (I)

  • can use combinations of these curves down the figure
  • use as few lines as possible
- Line of Action:
  • start by finding longest action line, a line that connects head to toes
  • always a directional flow if line doesn't connect from head to toe
- Relaxed and Tense curves:
  • 'bendiness' of the curve changes how it feels
    • long fluid curve feels relaxed
    • compress curve adds more energy and tension
    • compress curves far enough and you can use a 'zig zag'
      • tension
      • sharp corners
      • fast movement
    • Use ZIGZAG for tension 
    • Use FLOWING CURVE for smooth relaxed
- Asymmetry of Body
  • alternates:
    • head
    • neck
    • torso
    • pelvis
    • upper leg
    • lower leg
  • alternating C-curves that lead eye down body
  • tendency to draw symmetrically leads to stiffness
- PRACTICE: Draw MOTION, not CONTOUR

Monday, August 12, 2013

UNITY: Unity Strategy Games[2]: Mouse Click Feedback (tutorial)


  1. - Raycast information only stores the hit on the first thing it collides with.
  2. - can put object in 'ignore raycast layer'
  3. - nest animations under hierarchy layer: raycast hit to point item group to ground, then use script to animate item position itself for an animated object indicator.
  4. - Input.GetMouseButton(1); // mouse buttons:
    1. button 1 = 0 (Left)
    2. button 2 = 1 (Right)
    3. button 3 = 2 (scrollwheel)
  5. use animation panel to create animations within Unity.
  6. Animation system: can add keyframes and EVENTS.  Events can call for functions like in actionscripting.
  7. Destroy(this.gameObject);
    1. Destroys this game object.
//------------ code bit --------------
void DestroyObject()
{
     Destroy(this.gameObject);
}
//------- end code bit --------------

to destroy parent:


//------------ code bit --------------
void DestroyObject()
{
     Destroy(this.gameObject.transform.parent.gameObject);
}
//------- end code bit --------------



UNITY: Unity Strategy Games[1] Core Mouse Control (tutorial)

I've decided that the only way I'll remember any of the tutorials I've watched is to write notes.  Guess what I'll be using this blog for.

Unity: RTS Mouse Control (by Unity Chat):
http://www.youtube.com/watch?v=g1P2Q9xKCAs

Notes:
- Camera.ScreenPointToRay: draws a line from where you click on screen, to where it lands in 3D space.

- Debug.DrawRay(ray.origin, ray.direction*rayCastLength, Color.yellow);: Draws a yellow indicator of raycast hit.  Can only be seen in the 'SCENE' view.

- to put an item at the mouse location, tell the GameObject (whatever item you want at your mouse point) to make it's transform the position of the ray hit.

5 Fundamental Skills Every Artist Should Master

1. COMPOSITION
2. PERSPECTIVE
3. VALUE
4. COLOR
5. LIGHTING

http://psd.tutsplus.com/articles/theory/fundamental-skills/