hi Im trying to swap a texture that is always present in the middle of the screen. so that if it is over nothing it always shows the tooth, if it is over a person collider tagged “switch” the speech texture comes up and the tooth texture disappears, this i achieved.
Then i added another texture “pals” to swap when it was over a collider with the tag “pals” then the pals texture swapped ok, but the switch texture stopped working as soon as I added
I went through and made sure that they variables and ifs were balanced with true and false.
I am having the same issue.
The speech texture used to swap with the tooth texture until I added the leaf texture “else if” statement
Now the leaf texture is swapping with the tooth texture
But the speech texture isn’t swapping with the tooth texture
I hope that makes sense.
I have also seen that the variable is switching on and off as it should just the texture isn’t showing.
I have also paused the player and switched on and off the texture to make sure it is visible at the correct coordinates and it is showing ok.
var mouser : boolean;
var leaf1 : boolean;
var tooth : GUITexture;
var speech : GUITexture;
var leaf : GUITexture;
function Update() {
var hit : RaycastHit;
if (Physics.Raycast(transform.position, transform.forward, hit , 15)){
if(hit.collider.gameObject.tag == "switch"){
currentChar2 = hit.collider.gameObject;
mouser = true;
leaf1 = false;
}
else if(hit.collider.gameObject.tag == "pals"){
currentChar1 = hit.collider.gameObject;
leaf1 = true;
mouser = false;
}
else {
mouser = false;
leaf1 = false;
}
}
textureSwapper();
}
function textureSwapper(){
if (mouser == true){
tooth.enabled=false;
speech.enabled=true;
leaf.enabled=false;
}
if (leaf1 == true){
tooth.enabled=false;
speech.enabled=false;
leaf.enabled=true;
}
else {
tooth.enabled=true;
speech.enabled=false;
leaf.enabled=false;
}
}