Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
3
Question by Colin Allen · Apr 30, 2010 at 03:21 PM · movelevelnext

Move to next level on collide

Hey guys! I need help. I made a simple level and I want my character to collide with the "end point" (a simple cube) and go to the next level. Lots of scripts hate me and I want a script that makes me move to next level. I tried this one:

OnCollisionEnter()
{
application.LoadLevel();
}

and that didnt work.

Can you give me a script that makes me move to the next level please. (Also: should my character have anything special attached to him like a rigidbody???)

Thanks

Comment
Add comment · Show 5
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 HoshiHoshi · Sep 15, 2013 at 05:20 PM 0
Share

You have to put a scene name or scene number in the () of load level. It should look like this OnCollisionEnter() { Application.LoadLevel(1); }

avatar image ntawesome pickle · Oct 28, 2014 at 11:48 AM 0
Share

If I put in the scene name don't I have to put it in quotes

avatar image RHD · Nov 12, 2014 at 05:44 PM 0
Share

That actually WOR$$anonymous$$ED HURRAH!!!! Thank you.

avatar image Linus · Nov 12, 2014 at 05:45 PM 0
Share

Converted your answer to a comment under the question. Since its not clear what answer you where commenting on. Dont forget to mark correct answers(s) so the question is marked as answered.

avatar image RHD · Nov 12, 2014 at 05:48 PM 1
Share

Hi Linus,

I thought I'd posted my comment under the script that worked for me which wasn't the one you've moved it to. The one that worked for me was: var levelToLoad : String;

function OnTriggerEnter(hit : Collider) { Application.LoadLevel(levelToLoad); }

4 Replies

· Add your reply
  • Sort: 
avatar image
9

Answer by Ashkan_gc · Apr 30, 2010 at 06:12 PM

first you should add the scene to the list of scenes in file/build settings... menu. check the is trigger property of your character's collider. add a collider and a rigidbody to the box (end point). in rigidbody properties check the is kinematic property. then you can write

function OnTriggerEnter ()
{
Application.LoadLevel ("scenename");
}

have fun coding. scripts don't hate you :)

Comment
Add comment · Show 6 · 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 fredreis.du · Oct 05, 2011 at 07:26 PM 0
Share

I have to create a script file? Where do I put the code?

avatar image CLstream · Feb 16, 2013 at 08:53 PM 0
Share

The box collider I attached to a soda can instantly transports me to the next level without me touching it while I have "Is Trigger" checked on this script I put on the soda. HELP!

avatar image Darkvicos · Dec 14, 2013 at 04:49 AM 0
Share

is this javascript or c# script??

avatar image Hamtaro Darkvicos · Jan 25, 2016 at 02:27 AM 0
Share

I think its javascript

avatar image ntawesome pickle · Oct 28, 2014 at 11:43 AM 0
Share

As Soon As I start $$anonymous$$y Game It Loads New Level PLZZZZZ HELP

avatar image Cous · Nov 27, 2015 at 11:43 PM 0
Share

Would this go on the player movement script?

avatar image
2

Answer by Eric5h5 · Apr 30, 2010 at 06:02 PM

You have to specify the level to load in Application.LoadLevel. Also you have to write "Application" correctly (not "application"). You need a rigidbody if you want to have collisions.

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
2

Answer by karl_ · May 15, 2010 at 02:48 AM

Here's a completed script allowing you to set the next scene in the inspector. Make sure the plane/object you walk in to has "Is Trigger" marked. No rigidbody necessary.

//Script to revert winning player back to main menu

var levelToLoad : String;

function OnTriggerEnter(hit : Collider) { Application.LoadLevel(levelToLoad); }//END FUNCTION ONTRIGGERENTER

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 BluEye · Sep 05, 2012 at 11:01 PM 0
Share

@karl_ could you make the object transparent then still have the script saying when it hits that object it spawns it out of the game?

What if there is no next scene what if that is the end of the game? (For now I want to start with one level)

avatar image
2

Answer by CyberUnits · Jul 08, 2016 at 03:53 PM

@ntawesome pickle If the new level starts loading when starting your scene, than that probably means that the player already is touching an trigger collider. You could specify the object you want by adding an if statement.

Comment
Add comment · Show 2 · 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 $$anonymous$$ · Nov 27, 2020 at 01:38 PM 0
Share

can you plzzzzz specify how to specify an object

avatar image $$anonymous$$ · Nov 27, 2020 at 01:43 PM 0
Share

how to add that thing to the script plzzzz answer

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

13 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

Related Questions

Enabling the right script HELP!!! 1 Answer

How can I do the character parallel to geometry level 1 Answer

moving to next scene 1 Answer

move to next scene 1 Answer

open door to next level, after 10000 points were added to your score (solved) 2 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