how to lock rotation of Transform Unity code example
Example: unity how to lock rotation
public float lockPos;
void Update()
{
// Locks the rotation.
transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, lockPos, lockPos);
}