예제 #1
0
 private IEnumerator Oscillate(OccilationFunction method, float scalar)
 {
     while (true)
     {
         if (method == OccilationFunction.Sine)
         {
             transform.position = new Vector2((Mathf.Sin(Time.time) * scalar) + offSet, yLoc);
             yLoc -= ySpeed;
         }
         else if (method == OccilationFunction.Cosine)
         {
             transform.position = new Vector2((Mathf.Cos(Time.time) * scalar) + offSet, yLoc);
             yLoc -= ySpeed;
         }
         yield return(new WaitForEndOfFrame());
     }
 }
예제 #2
0
 private IEnumerator Oscillate(OccilationFunction method, float scalar)
 {
     while (true)
     {
         if (method == OccilationFunction.Sine)
         {
             if (method == OccilationFunction.Sine)
             {
                 transform.position = new Vector3(Mathf.Sin(Time.time) * scalar + startingPosition, transform.position.y, 0);
             }
             else if (method == OccilationFunction.Cosine)
             {
                 transform.position = new Vector3(Mathf.Cos(Time.time) * scalar + startingPosition, transform.position.y, 0);
             }
             yield return(new WaitForEndOfFrame());
         }
     }
 }