public Transform rotate;
public Rigidbody rb;
void Update()
{
if (rotate.transform.rotation.x == 50)
{
rb.constraints = RigidbodyConstraints.FreezeRotationX;
}
if (rotate.transform.rotation.x == -50)
{
rb.constraints = RigidbodyConstraints.FreezeRotationX;
}
if (rotate.transform.rotation.z == 50)
{
rb.constraints = RigidbodyConstraints.FreezeRotationZ;
Debug.Log("FreezeZ");
}
if (rotate.transform.rotation.z == -50)
{
rb.constraints = RigidbodyConstraints.FreezeRotationZ;
Debug.Log("-FreezeZ");
}
}