Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Scripts / Camera / MainMenuCamera.cs
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class MainMenuCamera : MonoBehaviour
  5. {
  6. [SerializeField] private float moveForce = 1f;
  7. private Vector3[] positionArray;
  8. private int pointsIndex;
  9. private Vector3 initialPos = new Vector3(-0.03f, 0.37f, -1f);
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. transform.position = initialPos;
  14. positionArray = new[] { new Vector3(7.72f, 9.6f, -1f), new Vector3(12.74f, 11.16f, -1f),
  15. new Vector3(12.74f, 20.49f, -1f), new Vector3(-2.39f, 20.49f, -1f),
  16. new Vector3(-2.39f, -0.28f, -1f), new Vector3(12.96f, -6.38f, -1f),
  17. new Vector3(-6.86f, 2.52f, -1f), new Vector3(-7.65f, -2.54f, -1f),
  18. new Vector3(-13.48f, 1f, -1f),new Vector3(-12.94f, 13.06f, -1f),
  19. new Vector3(-6.48f, 16.83f, -1f)};
  20. pointsIndex = 0;
  21. }
  22. // Update is called once per frame
  23. void Update()
  24. {
  25. transform.position = Vector3.MoveTowards(transform.position, positionArray[pointsIndex], moveForce * Time.deltaTime);
  26. if (transform.position == (positionArray[pointsIndex]))
  27. {
  28. //Next point of the array of Locations
  29. pointsIndex++;
  30. }
  31. if (pointsIndex == (positionArray.Length))
  32. {
  33. //Going Back to the start point
  34. pointsIndex = 0;
  35. }
  36. }
  37. }