Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

How can I extend the parameters to add also direction of the rotation ?

Discussion in 'Scripting' started by Chocolade, Jan 11, 2019.

  1. Chocolade


    Jun 19, 2013
    Code (csharp):
    2. private void RotateDegrees(Vector3 degrees,
    3.         params Animator[] anims)
    4.     {
    5.         Quaternion quaternion = Quaternion.Euler(degrees);
    6.         foreach (var anim in anims)
    7.         {
    8.             anim.transform.rotation = Quaternion.Slerp(anim.transform.rotation, quaternion, rotationSpeed * Time.deltaTime);
    9.         }
    10.     }
    For example using this method:

    Code (csharp):
    2. RotateDegrees(new Vector3(0, 0, 0), animators[0], animators[1]);
    But if I want to make that animators[0] will start rotating from right to left and animators[1] from left to right ?
    And do it in one line like I'm doing now but with a simple way to decide to what side it will rotate each object.