- Home /
HELP PLEASE!
Im making a game that when the ball hits the floor it will go to the gameover scene.
function OnTriggerEnter(collision : Collision){
if (collision.gameObject.tag == "BOOM"){
Application.LoadLevel ("2");
}
can you tell me whats wrong?
Why do all my questions always get bad votes or hate lol
Why do all my questions always get bad votes or hate lol
Since I'm not the one that voted you down, I cannot be sure, but titles should always reflect the content of the questions, and they never should be in all caps. "HELP PLEASE!" is not an appropriate title. In addition, since we cannot run your code, you need to explain what your code is doing or not doing.
Caps Lock and VERY vague titles are frowned upon here. In the menu just at the right of your screen. You'll see a nice little video tutorial that says how to ask good questions.
You could use some advices that are shown in this tutorial
Answer by getyour411 · May 20, 2014 at 04:03 AM
OnTrigger uses collider type, not collision; swap that and try again?
i changed it a little but it won't destroy when it hits the floor.
#pragma strict
function OnTriggerEnter(collision : Collider){
if (collision.gameObject.tag == ("BOO$$anonymous$$")){
Application.LoadLevel ("2");
}
}
Do I put the boom tag on the floor or the object that collides with the floor and where do I put the script. Also, should the floor have a box collider?
Answer by siddharth3322 · May 20, 2014 at 05:02 AM
You have to define your TriggerEnter function in following way.
function OnTriggerEnter (other : Collider) {
if (other .gameObject.compareTag("BOOM")){
Application.LoadLevel ("2");
}
}
If you want more information then please read manual. OnTriggerEnter
Answer by VIPINSIRWANI · May 20, 2014 at 05:04 AM
Make sure In Inspector window your Collider property isTrigger is true.
function OnTriggerEnter(collision : Collider){
if (collision.gameObject.tag == "BOOM"){
Application.LoadLevel ("2");
}
nvm i finally got it to work. Thanks for all the answers.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Trouble with a respawn script 1 Answer
Analysing player metrics help 0 Answers
Check if an object is at a relative position? 2 Answers
Damage on collision problems... 0 Answers