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 Vetpetmon · Nov 30, 2014 at 03:33 PM · not workingloadingbox collider

Trigger for reloading level won't work!

I have spent 4 hours trying to see what was wrong. No errors at all. The script is about using a object as a trigger when the player goes in it. I am using a box collider and a character controller. when the player falls into the trigger it restarts the level, but it's no doing it. The script(JavaScript):

 #pragma strict
 
 var Player : GameObject;
 
 function OnTriggerEnter (other : Collider) {
         Application.LoadLevel(0); //or whatever number your scene is
     }

Please give me the ENTIRE code, I never get what your talking about when you just put up a incomplete code. This is for my 2D game.

Comment
Add comment · Show 10
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 MrSoad · Nov 30, 2014 at 03:40 PM 1
Share

Try this :

1) You might need to use OnTriggerEnter2D

2) You have no check for if the collision is "Player", this will not stop it working but will mean it works with any object that enters...

3) When you do add a "Player" check make sure you have tagged your player as "Player"

avatar image smirlianos · Nov 30, 2014 at 04:01 PM 1
Share

I think Player is a reserved word

EDIT: Well, he may work on a 2.5D game, because he uses the Character Controller

avatar image MrSoad · Nov 30, 2014 at 04:17 PM 1
Share

True, but it is worth a try, the player var is never used so that is certainly not the reason why it is not loading the next level. But putting a Debug.Log in this like you said is a good idea. That will say weather or not it is the type of collision statement he has used that is wrong or the actual load level line. :)

avatar image smirlianos · Nov 30, 2014 at 04:19 PM 1
Share

Yes, it's true, that's why I asked him to put a Debug.Log.

avatar image b1gry4n · Nov 30, 2014 at 04:29 PM 1
Share

Is the code you are posting from the script $$anonymous$$illPlayer.js? If not you have errors in another script.

Also, your debug.log is not complete. Like stated above, put:

Debug.Log("test");

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Vetpetmon · Nov 30, 2014 at 04:42 PM

I found it! here's the code!:

 #pragma strict
 
  var player : GameObject;
  
  function OnTriggerEnter(other : Collider) {
      Debug.Log("Test") ;
      Application.LoadLevel(0);
  }
  
  
 

LOL, I had to label the both the objects player! I had completely cracked up when I found out! thanks for helping me! You can use this code if you want.

Comment
Add comment · Show 4 · 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 smirlianos · Nov 30, 2014 at 04:53 PM 1
Share

Hmm... strange! It dosn't matter in your code what tag the objects have

avatar image MrSoad · Nov 30, 2014 at 04:57 PM 0
Share

Agreed ????

avatar image b1gry4n · Nov 30, 2014 at 05:20 PM 1
Share

I think he is talking about layer? The two objects will not trigger if they are not set up correctly in the physics matrix

avatar image MrSoad · Nov 30, 2014 at 05:21 PM 0
Share

Thanks b1gry4n(+1), confusion had taken a firm hold upon my $$anonymous$$d :D

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

29 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

Related Questions

Colliders not working 1 Answer

Assets won't load 0 Answers

XML loading not working for built game 2 Answers

New project is taking a very long time to load 1 Answer

Colliders not working when used with a Rigidbody2D 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