Question by 
               Chavalier · Mar 07, 2016 at 11:57 PM · 
                javascripthingejointaccessingmultiple-objects  
              
 
              How can I access more Hinge Joints?
I made and openable box with hinge joints. When I press E on it, it sets the hinge.limit.max from 0 to 170. The problem is that it only affects the main object/prefab. Even when I try to open an other box that I placed with the prefab, only the main object/prefab opens.
Here is the script that I use.
 #pragma strict
 
 var testObj : GameObject;
 var hinge = gameObject.GetComponent(HingeJoint);
 var limits = hinge.limits;
 
 
 private var canHover : boolean = false;
 
 function Update()
 {
     var fwd = transform.TransformDirection(Vector3.forward); 
     var hit : RaycastHit; 
     
     if (Physics.Raycast(transform.position, fwd, hit))
     {
         if(hit.distance <= 5.0 && hit.collider.gameObject.tag == "box") 
         {
             canHover = true;
             
             if(Input.GetKeyDown("e"))
             {
                 
                 hinge.limits.max = 170;
 
             }
         }
   
         else
         {
             canHover = false;
         }
       }
 }
 
 function OnGUI()
 {
     if(canHover == true)
     {
         GUI.Box(Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 150, 20), "Open");
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Hinge Joint issue 0 Answers
Children of a hingejoint not colliding with parent's mesh when connectedBody is assigned 1 Answer
Modify "Humanoid" Animations 0 Answers
Check renderer color of object at Vector 3 location 0 Answers
How to disable LockTexture in case of LEVEL UNLOCK SYSTEM IN UNITY? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                