- Home /
 
 
               Question by 
               Patyrn · Feb 17, 2011 at 02:32 AM · 
                rotationvector3slerplookrotation  
              
 
              What am I doing wrong with these rotations?
 var targetVector : Vector3 = target.transform.position - turret.transform.position;
 
                var turretTargetVector : Vector3 = new Vector3(targetVector.x, 0, targetVector.z);
 var currentTurretVector : Vector3 = turret.transform.rotation * Vector3.forward;
 currentTurretVector.y = 0;
 turret.transform.rotation = Quaternion.LookRotation(Vector3.Slerp(currentTurretVector, turretTargetVector, Time.deltaTime));
 var barrelTargetVector : Vector3 = new Vector3(0, targetVector.y, targetVector.z);
 var currentBarrelVector : Vector3 = barrel.transform.rotation * Vector3.forward;
 currentBarrelVector.x = 0;
 barrel.transform.rotation = Quaternion.LookRotation(Vector3.Slerp(currentBarrelVector, barrelTargetVector, Time.deltaTime));
 
                
               
               The turret rotation works fine, rotating only on the y axis. The barrel rotation rotates on the y and x axis, when I only want it to use the x axis.
               Comment
              
 
               
              Your answer