Sunday, July 18, 2010

Reference: Pottery, rock and statues

Reference: Monuments and Pottery

Enemy Collider Script

Here is the collider script attached to the collider of the enemy


function Update () {
}
function OnTriggerEnter ( other : Collider) {

if (other.gameObject.tag == "player") {

enemymove.attacking=true;



}
}
function OnTriggerExit ( other : Collider) {

if (other.gameObject.tag == "player") {

enemymove.attacking=false;



}
}

Enemy Script

Heres a basic enemy script I created for the enemies to start with; once you come within their collider they start to come at you unit they touch or unit you escape their box collider or other shape maybe in the future. Again, we want to start simple master the move onto other things.

var enemy : GameObject;
var player : GameObject;
static var attacking = false;


function Update () {

if (attacking){
transform.LookAt(player.transform);
enemy.rigidbody.transform.Translate(2*Vector3.forward * Time.deltaTime);
}

}
function OnCollisionEnter (collisionInfo : Collision) {

if (collisionInfo.gameObject.tag == "player") {

attacking=false;

}
}

function OnCollisionExit (collisionInfo : Collision) {

if (collisionInfo.gameObject.tag == "player") {

attacking=true;

}
}

Code for camera

heres a code me and baker came up with for a camera might work nicely with our game

var targetThing : Transform;
var smoothness: float = 10;
var xOffset: float = 10;
var yOffset: float = 0;
var zOffset: float = 0;
var enableLookAt: boolean = false;

function Update () {
if (enableLookAt) {
transform.LookAt(targetThing.transform);
}
transform.position.x += (targetThing.transform.position.x - transform.position.x + xOffset) / smoothness;
transform.position.y += (targetThing.transform.position.y - transform.position.y + yOffset) / smoothness;
transform.position.z += (targetThing.transform.position.z - transform.position.z + zOffset) / smoothness;
}

Reference: Baskets

heres some baskets for reference