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 orangeflame · Sep 03, 2013 at 04:18 AM · collidercrashontriggerenterbullets

Getting hit with two bullets cause the game to crash [Solved]

Solution: I screwed up and at one point I was using random to generate a number from 1 to 3 and if it couldn't preform action 1 it would add 1 to the random number to do action 2 and so on. However, it appeared as if I was always hitting all of one action so to mix it up a little I made it go from 1 to 99 but I still had it only add 1. which means if it rolled a 1 and it could not preform action 1 it would keep adding one until it got to 34. Same for action 2 to 3 and 3 back to 1. Note: if it can't preform any of the action the formula would completely ignore this step all together.

In sort, I have a player that is hit with two bullets at the same moment and at that moment my game completely crashes or only registers one of the two bullets and ignores the other one. NOTE: when it only collides with one bullet everything works fine with no issues.

I am using OnTriggerEnter to preform the various actions that will happen when the player is hit by a bullet. I know this is a monster wall of script but I think I presented the main problem but here it is if it helps.

Comment
Add comment · Show 3
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 getyour411 · Sep 03, 2013 at 05:17 AM 1
Share

Check that lines 85 and 101 don't put you into an infinite loop

avatar image kork · Sep 03, 2013 at 09:54 AM 1
Share

You really should split that code up into several functions. $$anonymous$$akes it a whole lot easier to read plus you can ensure that each function works correctly before putting it all together.

avatar image orangeflame · Sep 03, 2013 at 08:59 PM 0
Share

Thank you getyour411. I did noticed I screwed up (because I'm lazy and use copy/paste) and had randNum >= 1 && randNum < 34 && in a lot of places it shouldn't be. I have fixed that and I will update the post soon. To kork, I have tested this with one bullet and saw that every line of code appeared to work under any condition but it only seems to crash when I have two bullets. I have not tested 3 or more but I doubt it will make much difference. I probablly could chop this up but like I said I believe this problem is not with my code but possible something wrong with OnTriggerEnter. I could wrong or may be wrong in using that. I know of oncollisionenter but long story sort I had a big fight with it and OnTriggerEnter wasn't giving me a problem.

NOTE: I am still having a problem. I just wanted to thank you for noticing some mistakes.

1 Reply

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

Answer by orangeflame · Sep 04, 2013 at 01:52 AM

Sorry everyone it turns out it was just an error in code and I literally got bad luck because of the random function and I must have always rolled a good number when testing the single hit.

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

17 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

Related Questions

Trigger and Collider Issues 1 Answer

OnTriggerEnter not working 0 Answers

Layers, parenting and collisions. 0 Answers

OnTriggerEnter not firing 1 Answer

percentage health bar 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