i need detailed instructions... cue texture

i have been rewriting this script over and over and maybe i’m just not putting it in the right place… but here we go.

function OnTriggerEnter (other: Collider){
    if(other.gameObject.tag == "Respawn"){
       renderer.material.mainTexture = Resources.Load("fluffacedead");
    }
}

i created a folder in my assets called Resources. i put the texture in that folder. i have little guys that run around with happy face textures on. when i stab them i want the texture to change to their dead face. i have tried many variations but cant get it to work. please help! here’s my layout. a poker that comes down with a button press… little guys that get stabbed. i think the script is fine but how should i set this up? and if the script isn’t fine than i am stumped beyond stumped. thanks in advance. this is driving me crazy.

Break this down into pieces:

  1. Try the Load on a line on it’s own. Can you successfully load the texture? Debug.Log it’s name or something, so you know it’s fetched.
  2. Set the texture on the material, perhaps when you press the space bar or similar, so you can check the setting of the texture to the material works.
  3. Debug.Log inside the OnTriggerEnter, so you know it’s called.
  4. Debug.Log the tag for the collided object, so you know what’s found.
  5. Debug.Log inside the if() so you can check it’s being called.

Nothing you’re doing looks tricky/difficult.