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 Layoken · Sep 16, 2013 at 12:13 AM · meshtriggerscenemeshcolliderswitching

How to change scenes by touching objects?

So I have multiple scenes in my game, and I want to have the player move between them by walking into a certain object (a mesh). How do I set this up where it changes the scene by detecting a collision? Thanks!

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by getyour411 · Sep 16, 2013 at 12:29 AM

Essentially:

OnCollision {

Application.LoadLevel("SceneName_in_BuildSettings_or_#");

}

Comment
Add comment · Show 3 · 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 Layoken · Sep 16, 2013 at 01:21 AM 0
Share

Thanks! It gave me the error "BCE0005: $$anonymous$$ identifier: 'OnCollision'."

So I modified it with another script I saw on here:

var target : Transform;

function OnCollisionEnter( collision : Collision ) {

Application.LoadLevel("0011");

}

and it "works" without errors - but it doesn't change the scene. :/ What am I doing wrong? (Sorry, I'm still a noob at JavaScript)

avatar image Layoken · Sep 16, 2013 at 01:57 AM 0
Share

I've also tried this variant:

 var collisionObject : GameObject;
  
 function OnCollisionEnter(collision : Collision){
 if (collision.gameObject.name == collisionObject){
 Application.LoadLevel("0011");
 }
 }

and changed the GameObject in question to a rigidbody, as where I got that script from suggested.....but it still doesn't work. :/

avatar image getyour411 · Sep 16, 2013 at 03:24 AM 0
Share

In your game's Build Settings, do you have a level named "0011" (literally)? If you use the quotes, it has to match the string name, without quotes it matches the # in the Build Settings.

avatar image
0

Answer by Mrawesome109 · Jan 10, 2018 at 01:38 AM

var collisionObject : GameObject;

function OnCollisionEnter(collision : Collision){ if (collision.gameObject.name == collisionObject){ Application.LoadLevel("0011"); } }

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

17 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

Related Questions

How would I detect water level at the player's position? 2 Answers

Loading player location in a scene 2 Answers

Will a mesh collider work as a parent of several meshes? 1 Answer

Add material and collider to a mesh imported from AutoCAD 0 Answers

Why does my trigger-collider receive Enter but not Stay or Exit? 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