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 PenguinPwnge · Apr 18, 2013 at 04:30 AM · collisiontrigger

Trigger won't load next level when Player enters it

I have a 2D side-scrolling platformer where a skater is jumping over crates. At the end of the level, I need the player to advance to the next level. The problem is that none of the scripts I've tried work. I have a plane sitting vertically for the player to enter and activate. On the plane, I have this script:

 var levelLoaded : int;
 
 function OnTriggerEnter(other : Collider){
     
     Application.LoadLevel(levelLoaded);
 
 }

The plane has a box collider on it, and "is trigger" is checked. The skater has a box collider and a rigidbody so it can collide with the crates (rigidbodies and box colliders). Anyone know why the script won't work?

I found the answer! The skater has to be moving for whatever reason. All of the other objects are moving instead of the skater because I'm stupid and that's what I wanted to do. So, I just made the skater have a line of code that moved him 0.001 units forward.

Comment
Add comment · Show 2
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 AlucardJay · Apr 18, 2013 at 10:05 AM 0
Share

1/ check the trigger is working :

 var levelLoaded : int;
 function OnTriggerEnter(other : Collider){
     Debug.Log( "Trigger was entered by : " + other.gameObject.name );
     Application.LoadLevel(levelLoaded);
 }


2/ make sure your levels are in the build setting menu : http://docs.unity3d.com/Documentation/$$anonymous$$anual/PublishingBuilds.html

avatar image fafase · Apr 19, 2013 at 09:09 AM 0
Share

Have you added your scene to the build? Did you give a value to levelLoaded?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Imankit · Apr 18, 2013 at 04:49 AM

You have to write :

  var levelLoaded : int;
      
     function OnTriggerEnter(other : Collider){
      if(other.gameObject.name == "skater"){
     Application.LoadLevel(levelLoaded);
 }
      
     }
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 basti · Apr 18, 2013 at 09:57 AM 1
Share

i don't think thats the problem. OnTriggerEnter is called when a rigidbody enters the trigger (ANY rigidbody). The if statement would become necessary if he wanted to distinguish different types of colliders.

avatar image Imankit · Apr 19, 2013 at 08:49 AM 0
Share

$$anonymous$$ay be his rigidbody id sleeping

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

15 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

Related Questions

How to add to a 3D object's length through code? 1 Answer

Overlap point of 2 kinematic colliders 1 Answer

How to add the right amount of points when my player destroys a gameobject? 0 Answers

Receiving information about getting hit by a Raycast 2 Answers

How do you execute Trigger-collider collision only in one gameobject? 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