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
1
Question by nickjeu · Nov 30, 2011 at 11:59 AM · ontriggerentertriggersbuild and run

Build and Run is breaking my triggers!

enter code hereThe title sums up my problem. I have a game that seems to run fine when I try to play it through the play button at the top of the screen. All of my scripts run just fine and no errors come up. Unfortunately, now that the game is done and we're ready to put it in the quarterly art show, we've run into a snag.

When we hit build and run, some of the triggers break.

The first simply triggers an animation on a swinging wrecking ball. I know the animation works, because another script that triggers it when I left click (for testing purposes) can sometimes trigger it. Then again some times I build the project it can't. I havn't changed anything, but the results sometimes differ!

 function Update () {
 }
 
 function OnTriggerEnter (other : Collider) {
 var swing : GameObject = GameObject.Find("Wreck");
 swing.animation.Play("wreck_swing");
 }

The second is similar. Its a trigger over a portion of walkway that drops out from under the player. Again, It can be triggered with click commands, but the trigger seems to fail entirely.

 function Update () {
 }
 
 function OnTriggerEnter (other : Collider) {
 var walkway : GameObject = GameObject.Find("Walkway");
 walkway.animation.Play("drop");
 
 }



I almost hope I'm doing something wrong. At least that way I can fix it and never have to deal with this again.

Thanks for your help in advance!

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 dannyskim · Dec 02, 2011 at 08:33 PM 0
Share

I'm not sure if this is a mistake on your part, but I don't ever use OnTriggerEnter inside of the Update loop, I'm surprised that it even compiles. Your code inside OnTriggerEnter seems perfectly legitimate, save for the fact that it's in update, and you should almost never use GameObject.Find inside of update.

Even for desktop platforms, it is highly suggested to call GameObject.Find on a SINGLE event, and cache the component rather than refreshing the reference every frame. I can see that this probably wasn't your intention, but just a forewarning.

avatar image WillTAtl · Dec 02, 2011 at 08:36 PM 0
Share

danny, think you just misread the {}s, that's an empty Update() function before OnTriggerEnter(). :)

avatar image dannyskim · Dec 02, 2011 at 09:00 PM 0
Share

Haha that's what happens when you stare at code all day my mistake. Have you tried using incollisionenter ins$$anonymous$$d? I'm assu$$anonymous$$g since they sometimes work that the istrigger is checked in the inspector? Have you tried putting a print to make sure that ontrigger is getting called?

avatar image Sparty · Jan 05, 2017 at 06:04 PM 0
Share

Any luck figuring this out. I am having the same problem. Triggers work in editor but not in build.

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

OnTriggerEnter doesnt see enemy 1 Answer

Can I make A trigger, Trigger the OnTriggerEnter Function 1 Answer

Updating a Value in OnTriggerEnter and Returning That Value Immediately... 0 Answers

How do I ignore trigger objects for collision? 0 Answers

show different textures when trigged entered thrice 2 Answers


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