Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-2
Question by justaskin324 · May 20, 2014 at 04:03 AM · javascriptcollisionontriggerenterscene-change

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?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image justaskin324 · May 21, 2014 at 03:48 AM 0
Share

Why do all my questions always get bad votes or hate lol

avatar image robertbu · May 21, 2014 at 04:18 AM 2
Share

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.

avatar image Clet_ · May 21, 2014 at 04:19 AM 1
Share

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by getyour411 · May 20, 2014 at 04:03 AM

OnTrigger uses collider type, not collision; swap that and try again?

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image justaskin324 · May 21, 2014 at 03:54 AM 0
Share

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?

avatar image
1

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

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");
     }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image justaskin324 · May 21, 2014 at 06:57 AM 0
Share

nvm i finally got it to work. Thanks for all the answers.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges