Permalink
Browse files

Week 3 examples up (finally!)

  • Loading branch information...
1 parent a452e99 commit 8cd9ca40221288c6998a926cbd7022eb5a4bc308 @obviousjim committed Feb 13, 2012
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
+public var materials : Material[];
+public var holdOnColor : float;
+private var lastChangedTime : float = 0;
+private var currentColorIndex : int = 0;
+function Update () {
+ if(Time.time - lastChangedTime > holdOnColor){
+ gameObject.GetComponent(MeshRenderer).sharedMaterial = materials[currentColorIndex % materials.length];
+ currentColorIndex++;
+ lastChangedTime = Time.time;
+ }
+}
@@ -0,0 +1,10 @@
+//public var materials : Material[];
+public var color1 : Color;
+public var color2 : Color;
+public var holdOnColor : float;
+private var lastChangedTime : float = 0;
+private var currentColorIndex : int = 0;
+function Update () {
+ var lerpValue : float = Time.time / 4.0;
+ gameObject.GetComponent(MeshRenderer).sharedMaterial.SetColor("_Color", Color.Lerp(color1, color2, lerpValue) );
+}
@@ -1,16 +1,20 @@
+//This was the particle test we tried together at the end of class
public var cubes : GameObject[];
public var boundingPlane : GameObject;
public var maxDistance : float = 100;
public var forcePower : float = 4;
+
function Update () {
var center : Vector3;
var i;
+ //find the center of all the cubes
for(i = 0; i < cubes.length; i++){
center += cubes[i].transform.position;
}
center /= cubes.length;
+ //move them all away
for(i = 0; i < cubes.length; i++){
var awayFromCenter : Vector3 = (cubes[i].transform.position - center).normalized;
var force : float = Mathf.Max(maxDistance - (cubes[i].transform.position - center).magnitude, 0);
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 8cd9ca4

Please sign in to comment.