Exemple #1
0
        // Update is called once per frame
        public void Update()
        {
            Vector3 dirCamera = Vector3.forward;

            if (dirOfObj)
            {
                dirCamera = -this.target.forward;
            }
            targetDir = target.position - horizontalDistance * dirCamera + height * Vector3.up;

            LerpVel = camVel * Mathf.Max(1,
                                         Vector3.Distance(targetDir, transform.position) / Mathf.Sqrt(Mathf.Pow(height, 2) + Mathf.Pow(horizontalDistance, 2)
                                                                                                      ));

            if (dodgeWall && Physics.Linecast(targetDir, target.position))
            {
                transform.position = targetDir;
                FayvitCameraSupport.DodgeWall(transform, target.position, 1, true, false);
            }
            else
            {
                transform.position = Vector3.Lerp(transform.position,
                                                  targetDir
                                                  , LerpVel * Time.deltaTime);
            }
        }
Exemple #2
0
        void FightFocus()
        {
            Vector3 direcaoDaVisao
                = Vector3.ProjectOnPlane(tEnemy.position - transform.position, Vector3.up);

            Quaternion alvoQ = Quaternion.LookRotation(direcaoDaVisao +
                                                       height / 10 * Vector3.down);

            x = Mathf.LerpAngle(x, alvoQ.eulerAngles.y, velMaxFocus * Time.deltaTime);
            y = Mathf.LerpAngle(y, alvoQ.eulerAngles.x, velMaxFocus * Time.deltaTime);

            Quaternion rotation = Quaternion.Euler(y, x, 0);

            Vector3 position = rotation * (new Vector3(0.0f, 0.0f, -distance)) + target.position
                               + (focusVerticalVar + height / 8) * Vector3.up;

            transform.rotation = Quaternion.Lerp(transform.rotation,
                                                 rotation,
                                                 50 * Time.deltaTime);

            transform.position = Vector3.Lerp(transform.position,
                                              position,
                                              50 * Time.deltaTime);

            FayvitCameraSupport.DodgeWall(transform, target.position, focusVerticalVar);
        }
        public void ShowAnother()
        {
            transform.position = TentativaDePosition();
            transform.LookAt(target);

            if (dodgeWall)
            {
                FayvitCameraSupport.DodgeWall(transform, target.position, characterHeight, true);
            }
        }
        public void ApplyCam(float moveX, float moveY, bool focar, bool autoAjust)
        {
            CamFeatures c = features;

            if (c.Target && c.MyCamera)
            {
                if (focar)
                {
                    IniciarFocarCamera(c);
                    State = StateCam.inFocusing;
                }
                else if (autoAjust && State == StateCam.controlable && c.velAutoAjust > 0)
                {
                    State = StateCam.inAutoAjust;
                }
                else if (State == StateCam.inAutoAjust && !autoAjust)
                {
                    State = StateCam.controlable;
                }

                if (State == StateCam.controlable)
                {
                    ControlableCam(moveX, moveY);
                }
                else if (State == StateCam.inFocusing)
                {
                    FocusInTheCamTarget(c.velToQ);
                }
                else if (State == StateCam.inAutoAjust)
                {
                    IniciarFocarCamera(c);
                    FocusInTheCamTarget(c.velAutoAjust);
                }

                SetPositionAndRotation();

                if (immediateFocusPosition)
                {
                    ImmediateFocusPosition();
                    FayvitCameraSupport.ClearSmooth();
                }
                else
                {
                    FayvitCameraSupport.DodgeWall(c.MyCamera, c.Target.position, c.varVerticalHeightPoint + c.HeightCharacter, true);
                }
            }
        }