Search Unity

Copying a world space rotation locally?

Discussion in 'Getting Started' started by CyberInteractiveLLC, Dec 2, 2018.

  1. CyberInteractiveLLC

    CyberInteractiveLLC

    Joined:
    May 23, 2017
    Posts:
    307
    Hi, i have 2 objects,

    Object 1: Rotates in world space
    Object 2: is a child of some other object


    i want to rotate object 2's localrotation to match that of Object 1... is there any way to do this ?
     
  2. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    Code (CSharp):
    1.  
    2. obj2.transform.localRotation = obj1.transform.rotation;
    3.  
     
  3. CyberInteractiveLLC

    CyberInteractiveLLC

    Joined:
    May 23, 2017
    Posts:
    307
    i didn't mean it like that... the rotations would be different
     
  4. Code (CSharp):
    1. obj2.transform.rotation = obj1.transform.rotation;