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 nodnarbisc · Feb 06, 2014 at 06:15 AM · collisionbuildgamecontroller

OnCollisionEnter Not Working After Game Build

This code works great in the editor, but after I build the game (I've tried building both standalone and web applications) the OnCollisionEnter function no longer runs. If it works correctly, when the player runs into a monster the game ends. Here's the code:

 void OnCollisionEnter(Collision collision)
    {
       if (this.tag == "Player" && collision.collider.tag == "Monster")
       {
     game.gameOver ();
       }
 }

Any ideas on why this wouldn't work after the build?

Comment
Add comment · Show 5
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 supernat · Feb 06, 2014 at 06:33 AM 0
Share

@nodnarbisc, are you sure this code is not running? I mean have you done some debugging to verify it is an issue with the collision? It could be a problem in gameOver(). If you are sure it's in this method, I have no ideas. Otherwise, please post gameOver().

avatar image nodnarbisc · Feb 06, 2014 at 03:09 PM 0
Share

@supernat Yeah I'm fairly sure its the OnCollisionEnter that's not working because I call game over() elsewhere and it works. Is there some build setting I need to change that might cause the built program to run differently than it does on the editor?

avatar image APenguin · Feb 06, 2014 at 03:22 PM 0
Share

I think you should post your gameOver(). Everything looks fine up there.

avatar image nodnarbisc · Feb 06, 2014 at 03:30 PM 0
Share

@APenguin, @supernat Here's the gameOver() code. Not much going on here.

     public void gameOver()
     {
         gameOverText.text = "YOU DIED. Press 'R' to restart.";
         over = true;
 
     }

I run this code either when the player hits a monster or if the player falls off the map. It runs when the player falls off the map because I use an OnTriggerEnter().

avatar image unimechanic ♦♦ · Feb 21, 2014 at 11:40 PM 0
Share

Did you try the last recommendations? Did they work? If you found a satisfactory answer to your question please respond it with the solution, that will be very helpful for future reference. Thanks for your comprehension, Unity Support.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by APenguin · Feb 06, 2014 at 03:48 PM

@nodarbisc, maybe use a OnTriggerEnter() for the monster as well see if that makes a difference. I am confused, because if it works in the editor then it should work when the game is built.

Comment
Add comment · 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

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

21 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

Related Questions

Distribute terrain in zones 3 Answers

Small resolution + full screen = everything is blurry! 0 Answers

My character falls of the map when build, but works ok in the editor 0 Answers

Unity changes the collisionDetectionMode in builds 1 Answer

2issues: Xbox Controller axis returns value that's constantly changing and a build problem. 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