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
0
Question by Thinkablevideos · Sep 05, 2014 at 07:23 AM · collisionscenechangescene change

Scene change on collision script?

So I got a script that's supposed to change the scene when the player collides with a certain block but it does nothing. But, when I toggle "Is Trigger" on the box collider, it will load the level and nearly IMMEDIATELY go to the scene i'm trying to go to.

 function OnTriggerEnter(other : Collider)
 {
   Application.LoadLevel("message");
 }
  

It's javascript and the level name i'm trying to change to is called "message".

Comment
Add comment · Show 7
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 Thinkablevideos · Sep 05, 2014 at 07:01 AM 0
Share

@zharik86 Still not working. These are my settings in the inspector: http://gyazo.com/a30138678782235a384b55f9c6bd80cf

avatar image CHPedersen · Sep 05, 2014 at 07:24 AM 0
Share

I don't see how that code even compiles. Application.LoadLevel is with capital "L"'s:

http://docs.unity3d.com/ScriptReference/Application.LoadLevel.html

avatar image Exbow · Sep 05, 2014 at 12:41 PM 1
Share

its cause of javascript. C# would flame you so much you would die from burning.

avatar image citizen421 · Sep 05, 2014 at 04:40 PM 0
Share

After you uncheck the trigger checkbox, can you output some kind of string to the console and see if it even detects the collision?

avatar image Yoscaron · Sep 06, 2014 at 03:44 AM 0
Share

Did you add the level "message" to the build scenes? $$anonymous$$aybe that's why it doesn't load

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AidanHorton · Sep 06, 2014 at 03:50 PM

The reason that your scene will load instantly, is probably because the character is colliding with the floor, which counts as OnTriggerEnter(). A way around this may be something like this:

 function OnTriggerEnter(other : Collider) {
      if (other.gameObject.tag == "block") {
           Application.Loadlevel(0);
      }
 }

Now obviously you would need to change the level thats being loaded (change the '0'), but also you need to tag the certain block with the tag "block", so that on a collision, if it detects a gameobject with the tag "block", then it loads the level. I haven't tested the code, but i'm sure some Googling would solve the problem. You could also try OnCollisionEnter(collision : Collision), and then do collision.gameObject.tag, but yet again I haven't tested it.

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

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

10 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

Related Questions

Scene Change Collision 2 Answers

how do you change a scene ingame? 1 Answer

How do I make a scene change when my Player collides with a item? 1 Answer

Scene Change on Player Collision 1 Answer

1 collider 2 fuctions, how? 1 Answer


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