hi for everyone! please, help with question
a have a script: the cannon turns where my camera turns. how to range cannon rotation from -90 to 90 degrees? sorry for my English
public float speed;
public Transform cannon;
public int mainCameraCurrentRot;
private Quaternion zeroRot;
void Start()
{
zeroRot = cannon.rotation;
}
void LateUpdate()
{
mainCameraCurrentRot = (int)mainCamera.transform.eulerAngles.y;
cannon.rotation = Quaternion.Slerp(cannon.rotation, zeroRot*Quaternion.AngleAxis(mainCameraCurrentRot, Vector3.forward), speed * Time.deltaTime);
}