Ejemplo n.º 1
0
    void Awake()
    {
        _uniqueInstance = this;
        _ltPositions    = new List <Vector3>();

        _posPlayer       = GameObject.FindWithTag("Player").transform;
        _curCameraAction = eStateCamera.FOLLOW;
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        switch (_curCameraAction)
        {
        case eStateCamera.NONE:
            _timeCheck += Time.deltaTime;
            if (_timeCheck > 2)
            {
                _curCameraAction = eStateCamera.WORKING;
            }

            break;

        case eStateCamera.WORKING:
            if (Vector3.Distance(transform.position, _ltPositions[_nextIndex]) <= 0.3f)
            {
                _curIndex  = _nextIndex;
                _nextIndex = _curIndex + 1;
                if (_nextIndex >= _ltPositions.Count)
                {
                    _nextIndex       = _curIndex;
                    _curCameraAction = eStateCamera.CHANGE_FOLLOW;
                }
            }
            transform.position = Vector3.MoveTowards(transform.position, _ltPositions[_nextIndex], Time.deltaTime * _movSpeed);
            transform.LookAt(_posPlayer);
            break;

        case eStateCamera.CHANGE_FOLLOW:
            Vector3    tp = _posPlayer.position + _followOffset;
            Quaternion tq = Quaternion.LookRotation(_lookPos.position - tp);
            transform.position = Vector3.Slerp(transform.position, tp, Time.deltaTime);
            transform.rotation = Quaternion.Slerp(transform.rotation, tq, Time.deltaTime * _rotSpeed);
            if (Vector3.Distance(transform.position, tp) <= 0.2f)
            {
                transform.position = tp;
                transform.LookAt(_lookPos);
                _curCameraAction = eStateCamera.FOLLOW;
            }
            break;

        case eStateCamera.FOLLOW:
            float currAngleY = Mathf.LerpAngle(transform.eulerAngles.y, _posPlayer.eulerAngles.y, Time.deltaTime);

            Quaternion rot = Quaternion.Euler(0, currAngleY, 0);
            _posGoal = _posPlayer.position
                       - (rot * Vector3.forward * _followOffset.z) + (Vector3.up * _followOffset.y);

            transform.position = Vector3.MoveTowards(transform.position, _posGoal, Time.deltaTime * 2 * _movSpeed);
            //transform.LookAt(_lookPos);

            //LobbyManager.INSTANCE.NOWGAMESTATE = LobbyManager.eGameState.PLYRUNNING;
            //PlayerControl._uniqueInstance.CURSTATE = PlayerControl.ePlayerActState.RUN;
            break;
        }
    }
Ejemplo n.º 3
0
 public void SetCaemraActionRoot(Transform tf)
 {
     _currentIndex = 0;
     _tfRootPos    = tf;
     for (int n = 0; n < _tfRootPos.childCount; n++)
     {
         _ltPositions.Add(_tfRootPos.GetChild(n).position);
     }
     transform.position = _ltPositions[_currentIndex];
     transform.LookAt(_tfRootPos);
     _nextIndex   = _currentIndex + 1;
     _cameraState = eStateCamera.NONE;
     _posPlayer   = GameObject.FindGameObjectWithTag("Player").transform;
     _lookPos     = GameObject.FindGameObjectWithTag("LookPos").transform;
 }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (InGameController._uniqueInstance.NOWGAMESTATE == InGameController.eGameState.END)
        {
            return;
        }

        switch (_cameraState)
        {
        case eStateCamera.NONE:
            // 2초 뒤에 카메라 동작..
            _timeCheck += Time.deltaTime;
            if (_timeCheck > 2)
            {
                _cameraState = eStateCamera.WORKING;
            }
            break;

        case eStateCamera.WORKING:
            if (Vector3.Distance(transform.position, _ltPositions[_nextIndex]) <= 0.3f)
            {
                _currentIndex = _nextIndex;
                _nextIndex    = _currentIndex + 1;
                if (_nextIndex >= _ltPositions.Count)
                {
                    _nextIndex   = _currentIndex;
                    _cameraState = eStateCamera.CHANGE_FOLLOW;
                }
            }
            transform.position = Vector3.MoveTowards(transform.position, _ltPositions[_nextIndex], _movSpeed * Time.deltaTime);
            transform.LookAt(_tfRootPos);
            break;

        case eStateCamera.CHANGE_FOLLOW:
            Vector3    tp = _posPlayer.position + _followOffset;
            Quaternion tq = Quaternion.LookRotation(_lookPos.position - tp);
            transform.position = Vector3.Slerp(transform.position, tp, Time.deltaTime);
            transform.rotation = Quaternion.Slerp(transform.rotation, tq, Time.deltaTime);
            if (Vector3.Distance(transform.position, tp) <= 0.2f)
            {
                transform.position = tp;
                transform.LookAt(_lookPos);
                _cameraState = eStateCamera.FOLLOW;
                InGameController._uniqueInstance.NOWGAMESTATE = InGameController.eGameState.START;
            }
            break;

        case eStateCamera.FOLLOW:
            float currAngleY = Mathf.LerpAngle(transform.eulerAngles.y, _posPlayer.eulerAngles.y, Time.deltaTime);

            Quaternion rot = Quaternion.Euler(0, currAngleY, 0);
            _posGoal = _posPlayer.position
                       - (rot * Vector3.forward * _followOffset.z) + (Vector3.up * _followOffset.y);

            // 이것을 해준 이유는 카메라 이동에따른 캐릭터프리팹과 카메라의 겹침 현상을 없애기 위해서이다.
            if (PlayerController._uniqueInstance.PLAYERACTION == PlayerController.ePlyAction.LANTERN_RUN ||
                PlayerController._uniqueInstance.PLAYERACTION == PlayerController.ePlyAction.RIFLE_RUN)
            {    // 플레이어가 랜턴을 들고 달릴 때
                transform.position = Vector3.MoveTowards(transform.position, _posGoal -
                                                         (rot * Vector3.forward * _followOffset.z * 3.5f), 2 * _movSpeed * Time.deltaTime);
            }
            //else if(PlayerController._uniqueInstance.PLAYERACTION == PlayerController.ePlyAction.LANTERN_JUMP
            //    || PlayerController._uniqueInstance.PLAYERACTION == PlayerController.ePlyAction.NOTHING_JUMP)
            //{// 플레이어가 랜턴을 들때와 안뜰때 점프
            //    transform.position = Vector3.MoveTowards(transform.position, _posGoal +
            //        (rot * Vector3.up * _followOffset.y * 3.5f), 10 * _movSpeed * Time.deltaTime);
            //}
            else
            {    // 플레이어의 나머지 행동
                transform.position = Vector3.MoveTowards(transform.position, _posGoal, 2 * _movSpeed * Time.deltaTime);
            }

            //transform.LookAt(_lookPos);
            break;
        }
    }