Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Copying a world space rotation locally?

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

  1. NewSystemGames

    NewSystemGames

    Joined:
    May 23, 2017
    Posts:
    303
    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. NewSystemGames

    NewSystemGames

    Joined:
    May 23, 2017
    Posts:
    303
    i didn't mean it like that... the rotations would be different
     
  4. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,900
    Code (CSharp):
    1. obj2.transform.rotation = obj1.transform.rotation;