Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- namespace Assets
- {
- public class MovePoly : MonoBehaviour
- {
- public Transform[] Targets;
- private int _tindex = 0;
- void Start()
- {
- transform.position = Targets[_tindex].transform.position;
- }
- void Update()
- {
- Move();
- }
- void Move()
- {
- transform.position =
- Vector2.MoveTowards(transform.position, Targets[_tindex].transform.position, Time.deltaTime);
- if (transform.position == Targets[_tindex].transform.position) _tindex += 1;
- if (_tindex == Targets.Length) _tindex = 0;
- }
- }
- }
Add Comment
Please, Sign In to add comment