Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 /
This question was closed Jul 07, 2015 at 05:11 PM by tanoshimi for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Abacab · Jul 07, 2015 at 03:22 PM · c#collisioncrashxcode

OnCollisionEnter causes crash

Hello!

The device should vibrate when I hit a wall, but when I hit one the game crashes. It doesn't crash if I comment out the OnCollisionEnter method, but it does crash if I only comment out

 if (Wall.gameObject.tag == "Wall") {
                 if (PlayerPrefs.GetInt ("VibrateIsOn") == 1) {
                     Handheld.Vibrate();
                 }

Commenting out this didn't help either:

 collision = true;

So only when I comment out the whole OnCollisionEnter -method it doesn't crash

THIS IS THE FULL SCRIPT:

 using UnityEngine;
 using System.Collections;
 
 public class CollisionTrigger : MonoBehaviour
 {
     public GameObject Wall;
     public static bool collision = false;
 
     void Start ()
     {
         collision = false;
     }
 
     void OnCollisionEnter ()
     {        
         if (Wall.gameObject.tag == "Wall") {
             if (PlayerPrefs.GetInt ("VibrateIsOn") == 1) {
                 Handheld.Vibrate();
             }
             collision = true;    
         }
     }
 }

Crash log:

  • thread #1: tid = 0x1519, 0x01049608 mazeracing`il2cpp::metadata::ArrayMetadata::GetBoundedArrayClass(TypeInfo*, unsigned int, bool) [inlined] il2cpp::metadata::SZArrayClassHash::operator(arrayClass=0x00000000)(TypeInfo const*) const at ArrayMetadata.cpp:379, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x28)

    frame #0: 0x01049608 mazeracing`il2cpp::metadata::ArrayMetadata::GetBoundedArrayClass(TypeInfo*, unsigned int, bool) [inlined] il2cpp::metadata::SZArrayClassHash::operator(arrayClass=0x00000000)(TypeInfo const*) const at ArrayMetadata.cpp:379 frame #1: 0x01049608 mazeracing`il2cpp::metadata::ArrayMetadata::GetBoundedArrayClass(TypeInfo*, unsigned int, bool) [inlined] std::__1::__unordered_map_hasher, il2cpp::metadata::SZArrayClassHash, true>::operator(__x=0x00000000)(TypeInfo* const&) const at unordered_map:384 frame #2: 0x01049608 mazeracing`il2cpp::metadata::ArrayMetadata::GetBoundedArrayClass(TypeInfo*, unsigned int, bool) [inlined] std::__1::__hash_iterator, void*>> std::__1::__hash_table, TypeInfo*>, std::__1::__unordered_map_hasher, il2cpp::metadata::SZArrayClassHash, true>, std::__1::__unordered_map_equal, il2cpp::metadata::SZArrayClassCompare, true>, std::__1::allocator > >::find(__k=0x00000000) at __hash_table:2020 frame #3: 0x01049608 mazeracing`il2cpp::metadata::ArrayMetadata::GetBoundedArrayClass(TypeInfo*, unsigned int, bool) [inlined] std::__1::unordered_map > >::find(this=, __k=0x00000000) at unordered_map:968 frame #4: 0x01049608 mazeracing`il2cpp::metadata::ArrayMetadata::GetBoundedArrayClass(elementClass=0x00000000, rank=1, bounded=false) + 168 at ArrayMetadata.cpp:459 frame #5: 0x01055648 mazeracing`il2cpp::vm::Array::New(elementTypeInfo=, length=) + 12 at Array.cpp:50 frame #6: 0x00968c0c mazeracing`ConvertContactToMono [inlined] CreateScriptingArray + 132 at ScriptingExportUtility.h:16 frame #7: 0x00968c08 mazeracing`ConvertContactToMono + 128 at MessageParameters.cpp:29 frame #8: 0x009aba96 mazeracing`HandleNotifications [inlined] Arguments + 248 at MonoBehaviour.cpp:1207 frame #9: 0x009ab99e mazeracing`HandleNotifications + 362 at MonoBehaviour.cpp:1276 frame #10: 0x00847b48 mazeracing`SendMessageAny [inlined] HandleMessage + 96 at MessageHandler.h:91 frame #11: 0x00847b3e mazeracing`SendMessageAny + 86 at GameObject.cpp:1185 frame #12: 0x00a849ee mazeracing`ProcessContacts [inlined] GetOtherRigidbodyOrCollider + 154 at GameObject.h:483 frame #13: 0x00a849d8 mazeracing`ProcessContacts + 132 at PhysicsManager.cpp:2435 frame #14: 0x00a83a42 mazeracing`ProcessRecordedReports + 30 at PhysicsManager.cpp:2489 frame #15: 0x00a8395a mazeracing`FixedUpdate + 1386 at PhysicsManager.cpp:1408 frame #16: 0x0096aa98 mazeracing`PlayerLoop + 896 at Player.cpp:1804 frame #17: 0x007b69d2 mazeracing`UnityPlayerLoopImpl + 14 at LibEntryPoint.mm:236 frame #18: 0x0005f7d8 mazeracing`UnityRepaint + 432 at UnityAppController+Rendering.mm:246 frame #19: 0x0005f590 mazeracing`__51-[UnityAppController(.block_descriptor=0x15d0d690) repaintDisplayLink]_block_invoke + 56 at UnityAppController+Rendering.mm:52 frame #20: 0x02f6019a libdispatch.dylib`dispatch_call_block_and_release + 10 frame #21: 0x02f60186 libdispatch.dylib`dispatch_client_callout + 22 frame #22: 0x02f63e9c libdispatch.dylib`dispatch_main_queue_callback_4CF + 1504 frame #23: 0x24b5b888 CoreFoundation`CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 8 frame #24: 0x24b59fa8 CoreFoundation`_CFRunLoopRun + 1512 frame #25: 0x24aa59a0 CoreFoundation`CFRunLoopRunSpecific + 476 frame #26: 0x24aa57b2 CoreFoundation`CFRunLoopRunInMode + 106 frame #27: 0x2c4671a8 GraphicsServices`GSEventRunModal + 136 frame #28: 0x28256634 UIKit`UIApplicationMain + 1440 frame #29: 0x000554c4 mazeracing`main(argc=, argv=) + 260 at main.mm:40 (lldb)

Comment
Add comment · Show 6
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 Dave-Carlile · Jul 07, 2015 at 03:59 PM 0
Share

So it crashes if you comment out Handheld.Vibrate? If that isn't a typo then how could that function call be causing the crash if it still crashes when you remove it?

Is Wall set to something or is it null? $$anonymous$$y first assumption would be that it's null.

avatar image Abacab · Jul 07, 2015 at 04:01 PM 0
Share

alt text

It wasn't a typo, but further testing revealed that it wasn't the reason.

screen-shot-2015-07-07-at-190101.png (14.1 kB)
avatar image _dns_ · Jul 07, 2015 at 04:42 PM 0
Share

Hi, have you tried to provide the full declaration for the OnCollisionEnter callback: void OnCollisionEnter(Collision collision). It might be an IL2CPP problem if the callback is not fully declared.

Also, you could add some "if ( Wall != null)" to be sure.

Another thing: using PlayerPref object during a collision is not a good practice: this function will go check the internal storage, this is very slow. I would store the result in a private variable that is initialized with calling playerpref only during Start, or making it a more global parameter for the whole game.

avatar image Abacab · Jul 07, 2015 at 04:48 PM 0
Share

Yes it started crashing when I changed to IL2CPP. I'll try with full declaration.

avatar image Abacab · Jul 07, 2015 at 05:07 PM 0
Share

Adding (Collision coll) solved the problem.

A huge thank you to both of you for your help. :)

Show more comments

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

23 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Can someone help me with the jumping in this Player Controller script? 1 Answer

OnTriggerEnter Not Working 1 Answer

My OnTriggerEnter2D(Collider2D other) not working 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