I know there are other questions similar to this on the forum, but I haven’t been able to make this work properly. I have a turret with a y-locked head and z/x-locked barrels. The head I can rotate just fine, but the barrels I haven’t been able to get down. This is the code I have for the barrels:
flatRotationBarrel = target.position - barrels.position;
flatRotationBarrel.x=0;
flatRotationBarrel.z=0;
barrelRotation = Quaternion.LookRotation(flatRotationBarrel);
barrels.rotation = Quaternion.Slerp(barrels.rotation, barrelRotation, Time.deltaTime*turnSpeed);
I get the feeling that Quaternion.LookRotation doesn’t like having only one axis to move on, as setting the head’s y to zero worked fine before. What can I do to fix it?