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
0
Question by achristopher · Jun 14, 2017 at 05:50 PM · colliderloadapplicationlevel load

Not Working properly. Application.LoadLevel

My player has the tag of FPSController, but when I collide with the plane that has that script, the level does not change, in build settings, the next level is 2

 void OnTriggerEnter(Collider other) {
     if (other.gameObject.CompareTag("FPSController")) {
         Application.LoadLevel (2);
     }
 }

Current Code:

 public class ToLevelTwo : MonoBehaviour {
 
 private string[] scenePaths;
 
 void OnTriggerEnter(Collider other) {
 
     if (other.gameObject.CompareTag("Finish")) {
 
     SceneManager.LoadScene(2);

Comment
Add comment · Show 4
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 achristopher · Jun 14, 2017 at 06:59 PM 0
Share

Current Code:

public class ToLevelTwo : $$anonymous$$onoBehaviour {

private string[] scenePaths;

void OnTriggerEnter(Collider other) {

 if (other.gameObject.CompareTag("Finish")) {

 Scene$$anonymous$$anager.LoadScene(2);
     }
 }

}

avatar image achristopher achristopher · Jun 14, 2017 at 06:59 PM 0
Share

(This isnt working)

avatar image SnStarrGames · Jun 14, 2017 at 07:53 PM 0
Share

Try explicitly comparing tag. So..

If(other.gameObject.tag == "Finish")

avatar image Habitablaba SnStarrGames · Jun 14, 2017 at 08:28 PM 0
Share

Using CompareTag is the appropriate thing to do here, ins$$anonymous$$d of directly checking string equality.

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Habitablaba · Jun 14, 2017 at 06:36 PM

Application.LoadLevel has been deprecated. You should be using SceneManager instead. Specifically, LoadScene

You can also use the override that takes a string to provide the name of a scene instead of the scene index, but that's really up to you.

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 achristopher · Jun 14, 2017 at 06:55 PM 0
Share

So should i not use application? when i replace LoadLevel with LoadScene, it makes the error: 'UnityEngine.Application' does not contain a definition for 'LoadScene'

avatar image achristopher · Jun 14, 2017 at 06:58 PM 0
Share

i added. using UnityEngine.Scene$$anonymous$$anagement; and it stopped the errors, but still it wont send me to scene 2

avatar image Habitablaba achristopher · Jun 14, 2017 at 08:29 PM 0
Share

Try using the name of the scene ins$$anonymous$$d of the index. Does this solve the problem? Are you using 2 as the index because your scene is 2nd in the list? I think the scene index may be 0 based (I don't have Unity accessible right now so I can't test to be sure), which would mean you actually want scene index 1 ins$$anonymous$$d of scene index 2

avatar image
0

Answer by Arcticstar · Jun 14, 2017 at 11:01 PM

Make sure to Add both scene to Build on the Build settings

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
0

Answer by Lupinus · Jun 14, 2017 at 11:12 PM

I had similar issues. Add a debug.log statement inside your OnTriggerEnter function and have it output a text message to the log. It doesn't matter what it says, just trying to determine if it's a loadscene issue, or if it's a triggering issue. Each would have different possible causes. Let us know whether or not the debug message shows up. :)

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
0

Answer by achristopher · Jun 15, 2017 at 08:54 PM

Stupid me, i forgot to make the plane's collider "Is trigger". My final script was:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.SceneManagement;

public class ToLevelTwo : MonoBehaviour {

private string[] scenePaths;

// Use this for initialization

void OnTriggerEnter(Collider other) {

     if (other.gameObject.CompareTag("Finish")) {

         SceneManager.LoadScene("Term Game 1");
     }
 }

}

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 Lupinus · Jun 19, 2017 at 10:45 PM 0
Share

Glad to hear it's working for you. We've all been there... myself included. :) And thanks for posting your fix... this may be helpful to others.

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

80 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Restarting a Scene 1 Answer

Don't destroy on load not working? 4 Answers

Why won't my terrain load. 0 Answers

How to create multiple ARworldmaps with ARKit using unity3d in a single app? 0 Answers

Loading bar with visual bar 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