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. Dismiss Notice

How Can I use LocalRotation as a variable?

Discussion in '2D' started by roan05112008, Sep 5, 2019.

  1. roan05112008

    roan05112008

    Joined:
    Sep 5, 2019
    Posts:
    17
    Hello!

    Can somebody help me with LocalRotation? I want to make it a variable, but it gives me an error. I tried every Vector type. Do I need to use another type? Please help me :) .
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    All rotational values in Unity are represented as Quaternions.
    Code (CSharp):
    1. public class Example : MonoBehaviour {
    2.    Quaternion localRot;
    3.  
    4.    void Start() {
    5.       localRot = transform.localRotation;
    6.    }
    7. }
    If you're using Visual Studio or any other IDE, placing your cursor over a field/property/method will show you what type it is.
     
  3. roan05112008

    roan05112008

    Joined:
    Sep 5, 2019
    Posts:
    17
    Thank you so much! It helped me a lot! Have a nice day! :)