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 AlexTheHollow · May 03, 2015 at 08:48 PM · 2dcollisiontriggerscene

Closed - Go to next scene on collision

I've looked at every tutorial, answer on here, and even in the stars but for the life of me, I can't get this to work.

2D Platformer

I'm trying to go to the next scene when the player enters the Cube I have set up.

Here's the code:

 using UnityEngine;
 using System.Collections;
 
 public class GoToScene2 : MonoBehaviour {
 
     void OnTriggerEnter2D(Collider2D other)
     {
         if (other.gameObject.tag == "Player")
             Application.LoadLevel(2);
     }
 }


The Cube is set to 0 for Gravity Scale, the Is Trigger is marked, and the Kinematic on Rigidbody2D is unchecked.

Any help?

I have solved the problem. I just added the second scene (which was named 2) to the Build Settings (so now there's 3 scenes. 1, 2, 2).

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by DoTA_KAMIKADzE · May 03, 2015 at 08:53 PM

1) Make sure that your player actually has "Player" tag.

To verify that above^ is OK and trigger works you can:

 if (other.gameObject.tag == "Player") Debug.Log("OK");

2) Make sure that in Build settings you have included your scene #2 in ScenesInBuild with position #2 on the right side of it.

Note: If you didn't know - you can use name of scene in LoadLevel instead of number.

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 AlexTheHollow · May 03, 2015 at 09:16 PM 0
Share

I got it to work earlier and forgot to close this. I just had to add it (again) to the Build Settings).

And the name of the scene was actually 2 :p

avatar image DoTA_KAMIKADzE · May 03, 2015 at 09:22 PM 0
Share

Well it doesn't matter which name it had/has in your code you use integer value that means that you use position of scene in Build settings not the name of scene.

avatar image AlexTheHollow · May 03, 2015 at 09:28 PM 0
Share

Well it doesn't matter anymore.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

collision2D not working - help? 2 Answers

Ignore a collider when there are multiple ones? 1 Answer

OnTriggerEnter2D using child's Trigger Box 1 Answer

Spike Player Die 0 Answers

2d game end level with trigger and colission with trigger who to make a if condition 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