Search Unity

More Collision Problems

Discussion in 'Scripting' started by JVILL, Mar 27, 2014.

  1. JVILL

    JVILL

    Joined:
    Dec 18, 2012
    Posts:
    6
    Yes, I realize there's already a million collider problem threads. I've already used the search bar and looked at 10 different threads but none are relevant to my problem.

    I have a Camera. It has a Box Collider attached. Here is a preview of the script attached:
    Code (csharp):
    1.  
    2. function Update ()
    3. {
    4. transform.Translate(0, 0, speed);
    5. }
    6.  
    7. function onCollisionEnter ( col : Collision )
    8. {
    9. //Debug
    10. print("hit");
    11.  
    12.     if ( col.gameObject.tag == "meteor" )
    13.     {
    14.     Destroy ( this.gameObject );
    15.     }
    16. }
    Camera has box collider, a rigidbody, and a control script.
    Meteors floating in space have a mesh collider (with Convex checked).
    Both colliders are NOT set to 'isTrigger'.
    Both rigidbodys are NOT set to 'isKinematic'.
    Use Gravity has been turned off for both rigidbodys.
    Yes, the Meteors are tagged correctly as "meteor", case-sensitive taken into account.

    I realize the issue may be that I'm using TRANSLATE instead of AddRelativeForce. I've tried AddRelativeForce as well, and no collision is ever detected. Note that visually the collision does occur.
    I've tried with Convex turned off for the Meteor mesh colliders.
    I've tried every possibly combination of Collision Detection methods, including 'Continuous Dynamic' on both Rigidbodys.
    Colliders were created by clicking the model and checking 'Generate Colliders'.
    I've also tried to change the speed via rigidbody.velocity, and that didn't work either. I'm just trying to detect the collision.

    I'm trying to upload the project via a package but it doesn't seem to be working.

    Thanks in advance for any assistance.
     
  2. SiegfriedCroes

    SiegfriedCroes

    Joined:
    Oct 19, 2013
    Posts:
    569
    Is that code you posted your actual code in Unity?
    Then you should try and change onCollisionEnter into OnCollisionEnter ;)
     
  3. JVILL

    JVILL

    Joined:
    Dec 18, 2012
    Posts:
    6
    Wow. I can't believe how unbelievably stupid I feel. I guess it's because no errors were being thrown that I didn't think of that.

    Cheers broham.