using UnityEngine; using System.Collections; using System.Collections.Generic; public class Boss1MovementSCript : MonoBehaviour { float counter; float timer = 5f; List positions; int i = 2; bool active; void Start () { positions = new List { new Vector3(120, 12), new Vector3(150, 12), new Vector3(135, 2.5f) }; } void Update () { if (active) { counter += Time.deltaTime; if (counter >= timer) { counter = 0f; gameObject.transform.position = positions[i]; i = ++i % 3; } } } public void EnableBoss1Movement() { active = true; } public void DisableBoss1Movement() { active = false; } }