Search Unity

Slerp in Worldspace, script problem

Discussion in 'Scripting' started by Mike343434, Jan 7, 2014.

  1. Mike343434

    Mike343434

    Joined:
    Apr 28, 2013
    Posts:
    75
    Hey guys,
    I just want to rotate in worldspace instead of an object´s local space. Here is thre line that actually moves it in local space. :
    Code (csharp):
    1. transform.rotation = Quaternion.Slerp(transform.rotation,desiredrot, Time.deltaTime * turnsmooth);
    "desiredrot" is specified some line above in this way:
    Code (csharp):
    1.         xangle=transform.rotation.eulerAngles.x;
    2.         yangle=transform.rotation.eulerAngles.y;
    3.         float tiltAroundY = Input.GetAxis ("Horizontal") * turningspeed+yangle;
    4.         float tiltAroundX = Input.GetAxis ("Vertical") * turningspeed+xangle;
    5.         float tiltz = Input.GetAxis ("Horizontal") * (-bankamount);
    6.         Quaternion desiredrot = Quaternion.Euler (tiltAroundX, tiltAroundY, tiltz+desiredzrot);
    So, do you know how I can make this object rotate in worldspace instead of it´s local space?

    Thanks, Mike :)