- Home /
Having problems with a Switch!
Hey Guys, im trying myself on a first unity projekt: a 2D sidescroller game. However, i have some issues using a switch. I made a texture, added a box collider and a script that activates gameobject that were deactivated before OnTriggerEnter. Heres my code:
public GameObject target,target2,target3,target4; public string tag = "Player";
void OnTriggerEnter(Collider other)
{
if (tag == "" || other.gameObject.CompareTag(tag))
{
}
}
void SchalterAwake()
{
target.SetActive (true);
target2.SetActive (true);
target3.SetActive (true);
target4.SetActive (true);
}
The Problem is that my player doesnt activate OnTriggerEnter when he steps into the box collider, just nothing happens : / and thats really frustrating as i need this feature!
I hope you guys can help me : )
Answer by koray1396 · May 07, 2014 at 08:52 PM
void OnTriggerEnter(Collider other)
{
if (tag == "" || other.gameObject.CompareTag(tag))
{
}
}
there is nothing inside the above. you have conditions, but nothing to perform. can you be trying this;
void OnTriggerEnter(Collider other)
{
if (tag == "" || other.gameObject.CompareTag(tag))
{
SchalterAwake();
}
}
Answer by TimmyFourSeven · May 07, 2014 at 10:25 PM
Aw men im such a idiot, no wonder it wont work!!
Thanks a billion times : )!
Your answer