コード例 #1
0
        public EnemyTarget GetEnemy(Vector3 from)
        {
            EnemyTarget r       = null;
            float       minDist = float.MaxValue;

            for (int i = 0; i < enemyTargets.Count; i++)
            {
                float tDist = Vector3.Distance(from, enemyTargets [i].GetTarget().position);
                if (tDist < minDist)
                {
                    minDist = tDist;
                    r       = enemyTargets [i];
                }
            }
            return(r);
        }
コード例 #2
0
        public void Init()
        {
            anim     = GetComponentInChildren <Animator> ();
            enTarget = GetComponent <EnemyTarget> ();
            enTarget.Init(anim);

            myBody             = GetComponent <Rigidbody> ();
            agent              = GetComponent <NavMeshAgent>();
            myBody.isKinematic = true;

            a_hook = anim.GetComponent <AnimatorHook> ();
            if (a_hook == null)
            {
                a_hook = anim.gameObject.AddComponent <AnimatorHook>();
            }
            a_hook.Init(null, this);

            ignoreLayers = ~(1 << 9);
        }