Example #1
0
        void LookAtCenter()
        {
            float y = -75;

            MyTransform.LookAt(new Vector3(0, y, 0), Vector3.up);
            MyTransform.SetLocalEulerAnglesX(MyTransform.localEulerAngles.x - 90f);
        }
Example #2
0
        private void Update()
        {
            if (!targetTransform)
            {
                return;
            }

            switch (option)
            {
            case Options.Standard:
                MyTransform.LookAt(targetTransform);
                break;

            case Options.YAxisOnly:
                var v = targetTransform.position - MyTransform.position;
                v.x = v.z = 0.0f;
                MyTransform.LookAt(targetTransform.transform.position - v);
                break;

            case Options.RotWithSlerp:
                RotateWithSlerp();
                break;

            case Options.RotThreshold:
                RotateWithinThreshold();
                break;

            case Options.RotWithSDA:
                RotateWithSDA();
                break;
            }
        }
Example #3
0
        private void UpdateFacing()
        {
            switch (faceObject)
            {
            case FacingType.None:
                break;

            case FacingType.Toward:
                MyTransform.LookAt(orbitObject);
                break;

            case FacingType.Away:
                MyTransform.LookAt(Position + Position.GetDir_AwayFrom(orbitObject.position));
                break;
            }
        }
Example #4
0
        private void Update()
        {
            if (_isDead)
            {
                return;
            }


            if (_isPatrol)
            {
                if (!_navMeshAgent.hasPath)
                {
                    _curIdleTime += Time.deltaTime;
                    if (_curIdleTime >= _idleTime)
                    {
                        _curIdleTime = 0;
                        Vector3     destinationPoint = _patrol.GetRandomPoint(MyTransform.position, _minRadius, _maxRadius, true);
                        NavMeshPath path             = new NavMeshPath();
                        bool        isWalkable       = _navMeshAgent.CalculatePath(destinationPoint, path);
                        if (isWalkable && path.status == NavMeshPathStatus.PathComplete)
                        {
                            _navMeshAgent.SetDestination(destinationPoint);
                        }
                    }
                }
                if (_vision.CalcVision(MyTransform, _target))
                {
                    _isPatrol = false;
                }
            }
            else
            {
                if (_vision.CalcVision(MyTransform, _target))
                {
                    float distance = Vector3.Distance(MyTransform.position, _target.position);
                    if (distance <= _attackRange && _weapon != null)
                    {
                        _weapon.Fire(_weapon.Ammo);
                    }
                    if (distance <= _stopRange)
                    {
                        if (_navMeshAgent.hasPath)
                        {
                            _navMeshAgent.ResetPath();
                        }
                        MyTransform.LookAt(_target.position);
                    }
                    else
                    {
                        _navMeshAgent.SetDestination(_target.position);
                    }
                }
                else
                {
                    _isPatrol    = true;
                    _curIdleTime = 0;
                }
            }
            if (_navMeshAgent.velocity != Vector3.zero)
            {
                SetAnimatorWalk(true);
            }
            else
            {
                SetAnimatorWalk(false);
            }
        }
Example #5
0
 void Start()
 {
     MyTransform.LookAt(new Vector3(0, -28.7f, 0), Vector3.up);
     MyTransform.SetLocalEulerAnglesX(MyTransform.localEulerAngles.x - 90f);
 }
Example #6
0
 void SetPosition(Vector3 a, Vector3 b)
 {
     Position = Vector3.Lerp(a, b, 0.5f);
     MyTransform.LookAt(b);
     OnSetPoints();
 }