Esempio n. 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);
        }
Esempio n. 2
0
        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);
        }