Hi I am new to unity so I am not super familiar with methods. I am trying to make my enemy rotate left then right double the amount that it rotated and back to the middle like this: +10 degree, -20 degree then +10 degree back to 0. I am trying transform.rotate however I believe I have a bad understanding of it and doing something wrong.
Edit: Even though I got the answer and it works the problem was that it inconsistently rotated like it went: +5 degree then -2 then +5 again. Next time I ran it it would be different values even though they were the same in the script.
Here is the method:
IEnumerator LookAroundArea(GameObject self)
{
if (10 >= Random.Range(1, 500))
{
Debug.Log("it runs");
self.transform.Rotate(new Vector3(0, 1, 0), 45 * Time.deltaTime * 45);
yield return new WaitForSeconds(1.0f);
self.transform.Rotate(new Vector3(0, -1, 0), 45 * Time.deltaTime * 90);
yield return new WaitForSeconds(2f);
self.transform.Rotate(new Vector3(0, 1, 0), 45 * Time.deltaTime * 45);
yield return new WaitForSeconds(1.0f);
}
dontrunagain = true;
}
```