Movement.cs 1013 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Movement.cs
  2. * author: Yannic Seidler
  3. */
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. // Class that rotates the robots in the SelectRobot scene.
  8. // Attached to GameObject RobotPresentation (Scene: SelectRobot).
  9. public class Movement : MonoBehaviour
  10. {
  11. public GameObject[] robots;
  12. // Start is called before the first frame update.
  13. void Start()
  14. {
  15. StartCoroutine(Move());
  16. }
  17. IEnumerator Move()
  18. {
  19. float sign = -1f;
  20. float startTime;
  21. for (; ; )
  22. {
  23. sign = -sign;
  24. startTime = Time.time;
  25. while (Time.time - startTime < 7f)
  26. {
  27. foreach (GameObject robot in robots)
  28. {
  29. robot.transform.Rotate(new Vector3(0, 45, 0) * sign * Time.deltaTime, Space.Self);
  30. }
  31. yield return null;
  32. }
  33. yield return new WaitForSecondsRealtime(3f);
  34. }
  35. }
  36. }