Question by 
               Bolt · Sep 23, 2017 at 11:28 AM · 
                rotationquaternionaxiscoordinatesworldspace  
              
 
              Combine two rotation
I'm doing tests. In my scene I have the enemy walking on a spherical world so it must rotate according to the world but at the same time it has to be oriented according to the direction of the player how can i do it?
 void Update () 
     {
         Vector3 dire = (pianeta.position - this.transform.position).normalized;
         float angleZ = Mathf.Atan2(dire.z, dire.x)*Mathf.Rad2Deg;
         Vector3 tar = (target.position - this.transform.position).normalized;
         float angleY = Mathf.Atan2(tar.y,tar.z) * Mathf.Rad2Deg;
         Quaternion dir = Quaternion.FromToRotation(this.transform.up, dire) * this.transform.rotation; // direction player by world
         this.transform.localRotation = Quaternion.Euler(0,angleY,0); //orientation by target position
        // this.transform.rotation = dir;
     }
 
              
               Comment
              
 
               
              Your answer