Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Created July 14, 2020 21:40
Show Gist options
  • Save unity3dcollege/a7ba0707246cdb4e9ce3928e0950cc77 to your computer and use it in GitHub Desktop.
Save unity3dcollege/a7ba0707246cdb4e9ce3928e0950cc77 to your computer and use it in GitHub Desktop.
int nextY = 0;
int direction = 1;
private void Update()
{
if (nextY == 90 || nextY == 0)
direction *= -1;
nextY += direction;
var nextRotation = new Vector3(transform.rotation.eulerAngles.x, nextY, transform.rotation.eulerAngles.z);
transform.rotation = Quaternion.Euler(nextRotation);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment