public IEnumerator MoveToPosition(vIControlAI controlAI)
            {
                lastTargetDirection = controlAI.transform.forward;
                onStartMove.Invoke();
                controlAI.SetSpeed(speed);
                controlAI.MoveTo(target.position);
                controlAI.ForceUpdatePath(2f);
                yield return(new WaitForSeconds(1));

                while (!controlAI.isInDestination && canMove)
                {
                    if (controlAI.remainingDistance > 2)
                    {
                        controlAI.MoveTo(target.position);
                        lastTargetDirection   = target.position - controlAI.transform.position;
                        lastTargetDirection.y = 0;
                    }
                    else
                    {
                        controlAI.StrafeMoveTo(target.position, rotateToTargetForward ? target.forward : lastTargetDirection);
                    }
                    yield return(null);
                }
                if (canMove)
                {
                    onFinishMove.Invoke();
                }

                else
                {
                    onCancelMove.Invoke();
                }
                canMove = false;
            }
        private IEnumerator Start()
        {
            controlAI = GetComponent <vIControlAI>();
            yield return(new WaitForEndOfFrame());

            if (moveToOnStart)
            {
                MoveTo(positionTarget);
            }
        }
Пример #3
0
        protected virtual void Start()
        {
            character          = GetComponent <vIControlAI>();
            animator           = GetComponent <Animator>();
            animatorStateInfos = new vAnimatorStateInfos(animator);
            animatorStateInfos.RegisterListener();
            if (animator.isHuman)
            {
                head = animator.GetBoneTransform(HumanBodyBones.Head);
                var spine1 = animator.GetBoneTransform(HumanBodyBones.Spine);
                var spine2 = animator.GetBoneTransform(HumanBodyBones.Chest);
                spine = new List <Transform>();
                if (spine1)
                {
                    spine.Add(spine1);
                }
                if (spine2)
                {
                    spine.Add(spine2);
                }
                var neck = animator.GetBoneTransform(HumanBodyBones.Neck);
                if (!hips)
                {
                    hips = animator.GetBoneTransform(HumanBodyBones.Hips);
                }
                if (neck && spine2 && neck.parent && neck.parent != spine2)
                {
                    spine.Add(neck.parent);
                }
            }

            if (head)
            {
                headHeight = Vector3.Distance(transform.position, head.position);
            }

            ResetOffseLookHeight();
            GetLookPoint();
            lookAroundProgress = 0.5f;
        }
Пример #4
0
            IEnumerator SetWaypointAreaToAI(vIControlAI controller)
            {
                yield return(new WaitForSeconds(setWaypointAreaDelay));

                controller.waypointArea = waypointArea;
            }
 public virtual void FindTarget(vIControlAI vIControl)
 {
     vIControl.FindSpecificTarget(_detectTags, _detectLayer, checkForObstacles);
 }