2
I need a Prefab to stop spinning when it reaches 2 positive values in Y. In case it reaches 65º. My code is like this, only it’s not working.
private float m_MaxYRotation = 65f;
private float m_MinYRotation = -65f;
private float velocity = 3;
private void Update() {
var eulerRotation = transform.rotation.eulerAngles;
eulerRotation.y = Camera.main.transform.eulerAngles.y;
if (eulerRotation.y < 270)
eulerRotation.y += 360;
eulerRotation.y = Mathf.Clamp(eulerRotation.y, 180 + m_MinYRotation, 180 + m_MaxYRotation);
transform.localEulerAngles = (Vector3.down * eulerRotation.y * velocity);