Guest User

Untitled

a guest
Aug 23rd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class NewBehaviourScript1 : MonoBehaviour
  6. {
  7.  
  8. // Use this for initialization
  9. void Start()
  10. {
  11. CallMoveMultiple();
  12. }
  13.  
  14. void CallMoveMultiple()
  15. {
  16. StopAllCoroutines();
  17.  
  18. Nodes.Clear();
  19. Nodes.Add(new MoveNode(new GameObject().transform, Vector3.zero, Vector3.up * 2.0f));
  20. Nodes.Add(new MoveNode(new GameObject().transform, Vector3.zero, Vector3.left * 2.0f));
  21.  
  22. StartCoroutine("MoveMultiple");
  23. }
  24.  
  25. List<MoveNode> Nodes = new List<MoveNode>();
  26. IEnumerator MoveMultiple()
  27. {
  28. foreach (var node in Nodes)
  29. {
  30. node.Transform.position = Vector3.Lerp(node.Start, node.End, Time.time);
  31. }
  32.  
  33. yield return null;
  34. }
  35. }
  36.  
  37. public class MoveNode
  38. {
  39. public Vector3 Start;
  40. public Vector3 End;
  41. public Transform Transform;
  42.  
  43. public MoveNode(Transform t, Vector3 s, Vector3 e)
  44. {
  45. Start = s;
  46. End = e;
  47. Transform = t;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment