Beispiel #1
0
 // Use this for initialization
 void Start()
 {
     if (parentobj == null)
     {
         parentobj = transform.parent.gameObject.GetComponent<StellarObject>();
         parentPos = transform.parent;
     }else{
         parentPos=parentobj.transform;
     }
 }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     if (parentobj == null)
     {
         parentobj = transform.parent.gameObject.GetComponent <StellarObject>();
         parentPos = transform.parent;
     }
     else
     {
         parentPos = parentobj.transform;
     }
 }
Beispiel #3
0
        void GetClostestAttPoint()
        {
            float shortest = Mathf.Infinity;
            float l = attracionPoints.Count;
            for (int i = 0; i < l; i++)
            {
                float dist = Vector3.Distance(attracionPoints[i].transform.position, transform.position);
                //Debug.DrawLine(transform.position, attracionPoints[i].transform.position);
                if (dist > 0 && dist < shortest)
                {
                    shortest = dist;
                    parentobj = attracionPoints[i].GetComponent<StellarObject>();
                    parentPos = attracionPoints[i].GetComponent<Transform>();

                }
                else if (dist < 0 && dist > shortest)
                {
                    shortest = dist;
                    parentobj = attracionPoints[i].GetComponent<StellarObject>();
                    parentPos = attracionPoints[i].GetComponent<Transform>();
                }
            }
        }