using MH; using System.Collections; using System.Collections.Generic; using UnityEngine; public class SpiritScript : UnitBase { public float speed = 10f; protected override void Update() { base.Update(); UnitBase hero = UnitManager.hero; Vector2 pos = transform.position; Vector2 heroPos = hero.transform.position; Vector2 dir = (heroPos - pos).normalized; pos += dir * Time.deltaTime * speed; this.GetComponent().flipX = dir.x < 0; transform.position = pos; } }