示例#1
0
        private void CheckTargets()
        {
            if (!generatedFollow)
            {
                generatedFollow = new GameObject(transform.gameObject.name + "-MomentLookTarget");
            }

            // Just for security, cleaning array if some objects to follow was deleted lately
            CleanArrayFromNulls(targetsInRange);
            CleanArrayFromNulls(importantTargetsInRange);

            // If important target is set, we looking at it (player)
            if (importantTargetsInRange.Count > 0)
            {
                //npcLookAnimator.ObjectToFollow = importantTarget;
                Transform target = GetNearest(importantTargetsInRange);
                generatedFollow.transform.SetParent(target, true);
                generatedFollow.transform.position = npcLookAnimator.TryFindHeadPositionInTarget(target);
                npcLookAnimator.SetMomentLookTransform(generatedFollow.transform);
            }
            else // In other situation, we will take nearest target
            if (targetsInRange.Count > 0)
            {
                //npcLookAnimator.ObjectToFollow = targetsInRange[0];
                Transform target = GetNearest(targetsInRange);
                generatedFollow.transform.SetParent(target, true);
                generatedFollow.transform.position = npcLookAnimator.TryFindHeadPositionInTarget(target);
                npcLookAnimator.SetMomentLookTransform(generatedFollow.transform);
            }
        }
        public void AssignToLookAnimator(FLookAnimator lookAnim)
        {
            if (!generatedFollow)
            {
                generatedFollow = new GameObject(transform.gameObject.name + "-MomentLookTarget");
                generatedFollow.transform.SetParent(transform);
                generatedFollow.transform.localPosition = offset;
            }

            lookAnim.SetMomentLookTransform(generatedFollow.transform);
            //lookAnim.SetLookTarget(generatedFollow.transform);
        }