in OnTriggerEnter (OTHER : Collider); what data is stored in the other? because for the past little bit i have been using as if it was a gameobject, but it isnt working out. so i would like to know what exactly it is reffering to there?
A Collider has direct access to the same inherited variables as a Transform or GameObject, like transform, gameObject, rigidbody, collider, name, tag etc. (take a look at the Inherited Variables in Collider to get a complete list).
EDITED: A game object has some basic variables (transform, collider, rigidbody, gameObject) that can be used as references to other variables of the same object. If you have transform, but want to get the gameObject reference, you can use transform.gameObject;
var invaderGameObject: GameObject;
var invaderTransform: Transform;
function OnTriggerEnter(other:Collider){
invaderGameObject = other.gameObject;
invaderTransform = other.transform;
}
EDITED2: The trigger script may declare targetAquired and monster as static variables, and read them in the tower script.
This is the trigger script:
static var targetAquired = false;
static var monster: GameObject;
function OnTriggerEnter (other : Collider) {
if(other.gameObject.CompareTag ("enemy")){
monster = other.collider.gameObject;
targetAquired = true;
}
}
function OnTriggerExit (other : Collider) {
if(other.gameObject.CompareTag ("enemy")){
targetAquired = false;
}
}
The tower script (below) must read the static variables using the name of the trigger script (what I suppose is attackRTriggerStay.js):
function Update () {
if (attackRTriggerStay.targetAquired){
transform.LookAt(attackRTriggerStay.monster.transform);
}
}