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 /
  • Help Room /
avatar image
0
Question by Jan182 · Aug 31, 2015 at 04:09 PM · triggernot workinglevel load

OnTriggerEnter does not work?

In my game I've set a tracking shot of the game world, which is a seperate unity file. However I've set a trigger at a specific point and after the camera has entered this trigger, the level, which is another seperate unity file, should load - but it does not. (yes, I've added all the levels in the "Build Settings")

I've been spending hours in trying to fix this but without success - hopefully anybody of you guys got an idea what could be wrong with code:

 #pragma strict
 
 public var checkenter : boolean = false; 
 
 function Start () {
     
 }
 
 function Update () {
     if (checkenter == true) {
         Application.LoadLevel("Level Jumper - Level1");
     }
 }
 
 function OnTriggerEnter () {
     checkenter = true;
     
 }

Thanks a lot for your help in advance!!

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

2 Replies

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

Answer by Landern · Aug 31, 2015 at 05:52 PM

You're missing the parameter for the function:

 function OnTriggerEnter(other : Collider)
 {
 // stuff
 }

Unity Engine needs to be able to match the function with parameters.

Edit: updated to use unityscript parameter and not c#, my mistake.

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 Jan182 · Aug 31, 2015 at 06:16 PM 0
Share

hmm I just tried that but then I get this error: "BCE0043: Unexpected token: other."

Do I have to define other?

sry but I'm quite a beginner ....

avatar image Landern · Aug 31, 2015 at 06:16 PM 0
Share

Opps, i put in the c# version, updating now.

avatar image Jan182 · Aug 31, 2015 at 06:31 PM 0
Share

now I have no errors, but unfortunately the trigger still doesn't work :(

Edit:

I've forgot to put the RigidBody component on the object. It works fine now. thank you very much!

avatar image
0

Answer by hexagonius · Aug 31, 2015 at 08:24 PM

the parameter is only necessary if you needed information about the object you triggered or collid with. The method function also works without.

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 Landern · Aug 31, 2015 at 08:35 PM 0
Share

This is true, it can match without the argument/parameter. I make it general rule that what the original poster posted might not reflect what they are actually building in the game assembly, thus the most used concept is with a collider reference passed into the method.

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

PLAYER NOT ACTIVATING TRIGGER WHEN ON TOP OF THE COLLIDER! IS THIS A BUG 0 Answers

Trigger code gives error 0 Answers

OnTriggerEnter 2 Answers

Teleportation script isn't working correctly when I go through my object trigger, I don't know why. 0 Answers

Collider not turning into trigger when painted to a scene 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