- Home /
Ball activating triggers even with a script
So I have been having a problem with my level. I have a ball that you can just for fun kick around and stuff, but there has been something occurring. If a player kicks the ball down a pathway which has a empty box which triggers a set of events to happen, it activates it even though I have some code telling the box to only activate when a item with the tag "player" enters it. Here is my code and I would appreciate if someone could tell me what I am doing wrong.
var appear: GameObject;
function Start () {
appear.active=false;
}
function OnTriggerEnter(other: Collider) {
if (other.tag == "Player")
appear.active=true;
}
So you're saying the ball is not tagged "Player" and the script is on the box, right?
Is the ball a child to the object tagged "Player"? $$anonymous$$aybe put the ball and 'player' on different collision layers and have the ball and trigger object's collision layers not interact (set it via Edit>Project Settings>Physics).
I simply fixed it using the collision layer matrix earlier, the ball just simply will not go down those hallways. Thanks for the help anyways, Just at a later time, Case closed. :P
Your answer
![](https://koobas.hobune.stream/wayback/20220613201344im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
VR : How to check if object held passed through trigger Zone 1 Answer
Can't click gameobject when over another trigger? 1 Answer
Undefind tag? 0 Answers
My script isn't detecting OnTriggerEnter why? 1 Answer
Making Sprite Disappear on Trigger 2 Answers