i’ve been at this for a day and a half at least and i cant see what im missing , i checked the syntax and the references ,everything should work but still it just wont.
i need to set the connectedBody of a joint on another gameObject to the gameObject the script is on , this is my code and it always results in adding the Fixedjoint and failing to change the connected body ,
i know i should get a reference to the joint when creating it but i even tried getting it manually to be sure that wasnt the problem,
im fairly sure the prblem isnt in getting witch rigidbody to attach it to but i still tryed every way i knew of attaching it to the rigidbody the script is in ,
does anyone have an idea what going on here ?
function Update (){
if(Input.GetButtonDown("p1pushl")){buttondown = true;}
if(Input.GetButtonUp("p1pushl")){buttondown = false;
StartCoroutine("dropgun");
}}
function OnCollisionEnter (c : Collision){
if(buttondown == true){
var joint = c.gameObject.AddComponent(FixedJoint);
joint.connectedBody=transform.rigidbody;
Debug.Log(joint.connectedBody);
}}