예제 #1
0
        public bool IsArrived()
        {
            TargetTransform TTF    = GetComponent <TargetTransform> ();
            Vector3         tgtPos = TTF._Target.position;

            Vector3 curPos = transform.position;
            Vector3 offset = tgtPos - curPos;

            offset.z = 0.0f;
            float dist = offset.magnitude;

            bool bArrive = (dist <= _DistThres);

            if (_bArrivePrev != bArrive)
            {
                if (bArrive)
                {
                    _Arrive.Invoke();
                }
                else
                {
                    _Leave.Invoke();
                }
            }
            return(bArrive);
        }
예제 #2
0
파일: SA_Seek.cs 프로젝트: oncy/AnimTech
        override public Vector2 EstimateOptimalVel()
        {
            TargetTransform TTF   = GetComponent <TargetTransform> ();
            Transform       tgtTF = TTF._Target;

            if (tgtTF == null)
            {
                return(Vector2.zero);
            }

            Vector3 TgtPos   = tgtTF.position;
            Vector3 CurPos   = transform.position;
            Vector2 ToTarget = TgtPos - CurPos;
            Vector2 opVel    = (Vector2)Vector3.ClampMagnitude(ToTarget, _MaxSpd);

            return(opVel);
        }