how to lock rotation of a object in 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);
}