- Home /
[c#] Texture-based Trigger?
Hello! I want to make a trigger with condition "when object1 with texture1 enters the trigger area, trigger is disabled." and "when object1 with texture other than texture1, trigger is enabled"
I'm sorry for my bad english... rage comic below will explain my question better...
anyone can help me?
Answer by whydoidoit · Jun 19, 2013 at 05:01 PM
So you could do something like this, which allows you to have a different function for each texture:
void OnTriggerEnter(Collider other)
{
var mainTexture = other.GetComponentInChildren<Renderer>().mainTexture;
if(mainTexture != null)
{
SendMessage("Hit" + mainTexture.name, other, SendMessageOptions.DontRequireReceiver);
}
}
Then on the trigger object in any script:
void HitTexture1(Collider otherObject)
{
//Do whatever
}
Or you could just do a switch or an if...
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
Texture BoxCollider2D in scene view only 1 Answer
how to make high quality textures with low size of downlaod 1 Answer
Material Not Reverting Back 2 Answers