In the Inspector each script has a different pair of values for Note1aTexture and Note1bTexture but in-game I can only ever pull up one texture – no matter how specific I am about referring to this script that’s being run from the object that just collided with the player. What am I doing wrong or failing to comprehend?
private var hasCollided: boolean = false;
private var usedState: boolean = false;
var labelText: String = "";
var Note1aTexture: Texture;
var Note1bTexture: Texture;
var pickupSound: AudioClip;
var pgWidth = Screen.width/2;
var pgHeight = Screen.height/1.5;
var pgW2 = pgWidth/2;
var pgH2 = pgHeight/2;
var pgX = 0;
var pgY = 0;
var pgMargin = 32;
function Update(){
if (hasCollided == true){
if (Input.GetKeyDown(KeyCode.E)){
if (this.usedState == true){
Destroy( transform.root.gameObject );
}
if (this.usedState == false){
this.usedState = true;
print("Player picked up item.");
audio.PlayOneShot(pickupSound);
if (tag == "Note"){
print("It was a note.");
}
}
}
}
}
function OnGUI()
{
if (usedState == true){
GUI.DrawTexture(Rect(pgX,pgY,pgWidth,pgHeight),this.Note1aTexture,ScaleMode.StretchToFill,true,0.0f);
GUI.DrawTexture(Rect(pgX+pgMargin*2,pgY+pgMargin,pgWidth-pgMargin*8,pgHeight-pgMargin),this.Note1bTexture,ScaleMode.StretchToFill,true,0.0f);
GUI.Box(Rect(140,Screen.height-50,Screen.width-300,120),("Press E to add to Journal; Space to put it down."));
if (Input.GetKeyDown(KeyCode.Space)){
this.usedState = false;
audio.PlayOneShot(pickupSound);
}
}
if (this.usedState == false){
if (this.hasCollided ==true){
GUI.Box(Rect(140,Screen.height/2,Screen.width-300,32),(labelText));
}
}
}
function OnTriggerEnter(c:Collider){
if(c.gameObject.tag =="Player"){
this.GetComponent.<PickUpNote1>().hasCollided = true;
}
}
function OnTriggerExit( other : Collider ){
this.GetComponent.<PickUpNote1>().hasCollided = false;
}