Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        sortList = gameObject.GetComponent <Octo_sort>();


        if (target != null && target.gameObject.activeSelf == true)
        {
            //transform.LookAt(target);
            Vector3 targetDir = target.position - transform.position;
            float   turnstep  = 0.5f * Time.deltaTime;
            Vector3 newDir    = Vector3.RotateTowards(transform.forward, targetDir, turnstep, 0.0F);
            //Debug.DrawRay(transform.position, newDir, Color.red);
            transform.rotation = Quaternion.LookRotation(newDir);
        }
        else if (target == null || !target.gameObject.activeSelf == true)
        {
            Pool   = sortList.passZone();
            target = Pool.lockon(transform);
        }

        if (target == null)
        {
            target = forward;
        }
        transform.position = Vector3.MoveTowards(transform.position, target.position, step);
    }
Esempio n. 2
0
 public void getNewTarg()
 {
     target = sortList.passZone().lockon(transform);
     // bounce--;
 }