- Home /
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.
Answer by Graham-Dunnett · Jul 07, 2013 at 09:32 AM
Break this down into pieces:
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.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.
Debug.Log
inside theOnTriggerEnter
, so you know it's called.Debug.Log
the tag for the collided object, so you know what's found.Debug.Log
inside theif()
so you can check it's being called.
Nothing you're doing looks tricky/difficult.
i'm still having quite a bit of trouble. if i put the script on the poker trigger the error says there is not renderer on the trigger...which i realize. if i put the script on the mesh of the character i get no reaction what so ever. i even tried using the load lines by themselves and upon start up there was no change. i am totally stumped. can anyone help me?
Your answer
Follow this Question
Related Questions
on trigger enter 1 Answer
fetching a value 1 Answer
OnTriggerEnter problem 3 Answers
OnTriggerExit() help 0 Answers