/// <summary> ///创建血条 /// </summary> public BooldFollow CreateBooldBar(Transform target) { //执行血条的实例化 GameObject go = Instantiate(booldBar) as GameObject; //设置父级 go.transform.parent = this.transform; //设置局部坐标为原点 go.transform.localPosition = Vector3.zero; //到这里面我们需要解决两个问题:1、是由谁创建的这个血条,2、血条出来该跟着谁 //血条创建后,我们可以通过传递target传到血条身上 BooldFollow boold = go.GetComponent <BooldFollow> (); boold.SetFollowTarget(target); return(boold); }
// Use this for initialization void Start() { anim = GetComponent <Animator>(); totalHp = hp; bf = BooldManager.instance.CreateBooldBar(booldTarget); }