Basic AI Scripting

proximityDetector.js

var player_pos : Transform;

function Update () {
if (Vector3.Distance(player_pos.position,
transform.position) < 10){

renderer.material.color = new Color(1.0, 0.0, 0.0);
} else {
renderer.material.color = new Color(1.0, 1.0, 1.0);
}
}
——————————————

LookAt.js

var player_pos : Transform;

function Update () {
transform.LookAt(player_pos.position);
}
——————————————

Chase.js

var player_pos : Transform;

function Update () {
transform.position =
Vector3.MoveTowards (transform.position,
player_pos.position,
0.05);
}

Class 020 – Assignment 1 – Unity Progress

Class 020 – Assignment 1

“Unity Progress”

1) Take the research you did for last class and polish it up based on the feedback and troubleshooting from class.

2) Combine it with the work from your teammates to compile an initial build of your unity prototype.

3) Post the URL to your individual student blog documentation below as a comment.

Timestamp Due: 11/19/2012, 7:00p

Class 019 – Assignment 1 – Long Term Project Unity Todo List

Class 019 – Assignment 1

“Unity Todo List”

1) Choose one of the below unity topics to research for your team (one per student):

Prophecy:
1) Growth – procedural splines
2) Interaction – proximity detection, key presses
3) Death/Respawn
4) Alternating Speeds
5) Health System

Creschendo:
1) Destructibles/Destroy function
2) Shooting out a sound wave – shaders, key press, collisions
3) Reversing time – logging system, stacks
4) Restoring color – shaders, keyframing

Delusion:
1) Changing Terrain
2) Gravity Shift
3) Moving Cameras/Change FOV
4) Enabling/Disabling Collideable Walls
5) Glowing Orb – Shader

2) Research the code needed to complete it, and implement a sample of this system in Unity.

3) Post the URL to your individual student blog documentation below as a comment.

Timestamp Due: 11/14/2012, 7:00p

Unity – Class 007 – Collisions Tutorial


Gate.js

———————

#pragma strict
static var showWorldBarrier : boolean;

function Start ()
{
gate.showWorldBarrier = false; // start out with the world barrier invisible
}
//occurs anytime a collider hits the box
function OnTriggerEnter (c : Collider)
{
if(c.gameObject.name==”player”) //if that collider’s gameObject is named ‘player’
{
showWorldBarrier = !showWorldBarrier; //toggle the global boolean variable
}
}

————————-
worldBarrier.js

—————————–

#pragma strict

function Update ()
{
if(gate.showWorldBarrier != this.renderer.enabled) //if the boolean for showing walls is different than the boolean for making the walls invisible
{
this.renderer.enabled = gate.showWorldBarrier; //gameObject.renderer.enabled is true if we’re showing the object and false if not
}
}