- Home /
Troubleshoot C# collision trigger
I have this exact same type of trigger for another game, however THIS one isn't working, and I cannot see/figure out why not.
void OnTriggerEnter(Collider otherObject)
{
//if ball goes off the visible plane
if (otherObject.tag == "outOfBounds")
{
Ball.Lives--;
outOfBounds outOfBounds = (outOfBounds)otherObject.gameObject.GetComponent("outOfBounds");
//play sound effect
//wait and reset ball and plane
}
}
It's simple, and there to my eyes, that all I want is when "Ball" and "outOfBounds" collide that you subtract 1 life (yes, this is the script for the Ball).
In case it's needed, the outOfBounds script looks like this:
void OnTriggerEnter(Collider otherObject)
{
if (otherObject.tag == "Ball")
{
Ball Ball = (Ball)otherObject.gameObject.GetComponent("Ball");
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Enemy Collision Wont Work! PLEASE HELP 0 Answers
how to morph character on collision enter with gameobject 1 Answer
Hit Collision with exceptions 2 Answers
Collision detection accuracy issues. 1 Answer