- Home /
LocalRotation does not work
why LocalRotation does not want to work in this line gmo.transform.localRotation = Quaternion.identity;
here is the script
 void Start()
      {
          rb = GetComponent<Rigidbody>();
      }
      void OnTriggerStay(Collider other)
      {
          if (other.CompareTag("Player"))
          {
            
             
                 invite = true;
                 rb.isKinematic = true;
                 rb.detectCollisions = true;
                 if (timeCount >= 2.0f)
                 {
                     
                     rb.isKinematic = false;
                     rb.detectCollisions = false;
                     transform.SetParent(other.transform, true);
 
                 gmo.transform.localRotation = Quaternion.identity;
 
                 BlazeIt = gameObject.GetComponent<HingeJoint>();
                     BlazeIt.connectedBody = targetJoint;
 
                     Debug.Log("Good");
                 }
                 timeCount = timeCount + Time.deltaTime;
 
             
 
 
          }
      }
 
     void Update()
     {
 
 
         if (invite == true)
         {
             if (Input.GetKey(KeyCode.T))
             {
                 transform.position = Vector3.Lerp(startMarker.position, targetTransform.position, timeCount);
                 gmo.transform.localRotation = Quaternion.identity;
                 // transform.DORotate(pos, duration, RotateMode.Fast);
             }
         }
         
 
        
 
     }
 
 }
 
You will have to explain what makes you say "it does not work". The local rotation is the rotation in the local space of the parent gameObject. So after calling gmo.transform.localRotation = Quaternion.identity;, gmo will be aligned with its parent. 
There are two objects A and B. To become a child of And with SetParent and then LocalRotation should have worked
gmo is the one whose object you want to use LocalRotation for sure
 public GameObject gmo;
Answer by cs120319992 · Mar 21, 2019 at 05:44 PM
*gmo.transform.rotation = Quaternion.identity;
localRotation and rotation are different. The first one means the rotation in the local space of the parent object while the 2nd one means the rotation in the world space. 
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                