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

Multiplying the rotation of an object

Discussion in 'Scripting' started by Rutenis, Aug 16, 2014.

  1. Rutenis

    Rutenis

    Joined:
    Aug 7, 2013
    Posts:
    297
    Hey, so quick question, how do i multiply rotation of an object by any number? For example, i wanna flip the rotation, just by multiplying it by -1. So bassically, i dont know how to check whats the current rotation of an object. Sounds simple, yet cant figure it out...

    -Thanks!! :))
     
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,680
    I would use EulerAngles() to know current rotation values.
     
  3. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    Why not just add 180?
     
  4. Rutenis

    Rutenis

    Joined:
    Aug 7, 2013
    Posts:
    297
    Thats the problem, i understand how eulerAngles work, but i dont know how to use it to check whats the CURRENT rotation of an object. I just simply want to see my current z rotation and multiply it by -1.

    Thats not how it works for me. Yet, still i wouldnt know how to add "180", thats my question.
     
  5. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
    Code (csharp):
    1. Vector3 newEulerAngles = transform.eulerAngles;
    2. newEulerAngles.z += 180f;
    3. transform.eulerAngles = newEulerAngles;
     
    Last edited: Aug 17, 2014
  6. Rutenis

    Rutenis

    Joined:
    Aug 7, 2013
    Posts:
    297
    Yes, thanks. :)
     
  7. MasUno_YT

    MasUno_YT

    Joined:
    Jul 12, 2020
    Posts:
    1
    YEEESS THANKS I´VE BEEN 3 HOURS SEARCHING FOR THIS SOLUTION XDDD