Search Unity

Fixed Joint added during runtime not showing up in inspector

Discussion in 'Scripting' started by keithsoulasa, Dec 6, 2012.

  1. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Hi all, I'm trying to get a fixed joint to add to a gameobject and then attach to another object , but its not showing up in the inspector

    Code (csharp):
    1.  
    2.  
    3. void OnCollisionEnter(Collision collision)
    4.     {if(true)
    5.         {
    6.             if (First)
    7.             {
    8.  
    9.       FixedJoint J = gameObject.AddComponent("FixedJoint") as FixedJoint;
    10.                 J.connectedBody = collision.rigidbody;
    11.                 J.breakForce = 0.01f;
    12.                 J.breakTorque = 0.01f;
    13.             //    print(gameObject.name);
    14.                 First = false;
    15.                 print(J.connectedBody.gameObject.name+ "connected too");
    16.                 // J.connectedBody = collision.rigidbody;
    17.  
    18.             }
    19.  
    20.         }
    21.     }
    22.  
    This line
    Code (csharp):
    1.  
    2.  print(J.connectedBody.gameObject.name+ "connected too");
    3.  
    works fine and it prints out a name, which would mean the fixed joint is being created . But it doesn't show up in the inspector . Any ideas .