Пример #1
0
 private void FixedUpdate()
 {
     //  Every frame get the mouse x and y input
     xAxis.Update(Time.fixedDeltaTime);
     yAxis.Update(Time.fixedDeltaTime);
     //  Follow the target object rotation
     cameraLookAt.transform.rotation = Quaternion.Euler(yAxis.Value, xAxis.Value, 0f);
 }
        private void Update()
        {
            if (Brain == null)
            {
                return;
            }

            HorizontalAxis.Update(Time.deltaTime);
            VerticalAxis.Update(Time.deltaTime);

            PlaceTarget();
        }
 // Create method to zoom the thirdPersonCamera in and out
 private void Zoom()
 {
     if (tpcOrbits != null & !firstPerson & !chatUIWindow.GetComponent <ChatWindowController>().mouseOver)
     {
         zAxis.Update(Time.deltaTime);
         float scale = Mathf.Lerp(minScale, maxScale, zAxis.Value);
         for (int i = 0; i < tpcOrbits.Length; i++)
         {
             thirdPersonCamera.m_Orbits[i].m_Height = tpcOrbits[i].m_Height * scale;
             thirdPersonCamera.m_Orbits[i].m_Radius = tpcOrbits[i].m_Radius * scale;
         }
     }
 }
Пример #4
0
        void FixedUpdate()
        {//Control the follow of the camera
            if (hasAuthority)
            {
                xAxis.Update(Time.fixedDeltaTime);
                yAxis.Update(Time.fixedDeltaTime);
                cameraLookAt.eulerAngles = new Vector3(yAxis.Value, xAxis.Value, 0);

                //Rotate the character towards the camera
                float yawCamera = UnityEngine.Camera.main.transform.rotation.eulerAngles.y;
                transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, yawCamera, 0), turnSpeed * Time.fixedDeltaTime);
            }
        }
        public void TestRecentering(float minValue, float maxValue, bool wrap,
                                    float maxSpeed, float accelTime, float decelTime, bool invert, float axisValue,
                                    bool enabled, float recenteringTime, float expectedValue)
        {
            var axisState = new AxisState(minValue, maxValue, wrap, false, maxSpeed, accelTime, decelTime, null, invert);

            axisState.SetInputAxisProvider(0, new TestAxisProvider(axisValue));
            axisState.Validate();

            var success = axisState.Update(1.0f);

            Assert.IsTrue(success, "Update had no effect");
        }
Пример #6
0
    private void FixedUpdate()
    {
        if (GMI.isGameOver || GMI.isLoading || GMI.isInteractioning)
        {
            return;
        }
        float yawCamera = mainCamera.transform.rotation.eulerAngles.y;                                                                 // 카메라의 y축 각도

        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, yawCamera, 0), turnSpeed * Time.fixedDeltaTime); // 캐릭터가 카메라의 회전에 대응하여 회전 하는 것

        cameraLookAt.eulerAngles = new Vector3(yAxis.Value, xAxis.Value, 0);

        xAxis.Update(Time.fixedDeltaTime);
        yAxis.Update(Time.fixedDeltaTime);
    }
Пример #7
0
        /// <summary>
        /// Allows us to zoom with FreeLook camera.
        /// </summary>
        /// <param name="minScale"></param>
        /// <param name="maxScale"></param>
        public void UpdateOrbit(float minScale = 0.5f, float maxScale = 1)
        {
            minScale = Mathf.Clamp(minScale, 0.01f, 1f);
            maxScale = Mathf.Clamp(maxScale, 1f, 5f);

            if (m_originalOrbits != null)
            {
                zAxis.Update(Time.deltaTime);
                float scale = Mathf.Lerp(minScale, maxScale, zAxis.Value);
                for (int i = 0; i < m_originalOrbits.Length; i++)
                {
                    m_cmFreeLook.m_Orbits[i].m_Height = m_originalOrbits[i].m_Height * scale;
                    m_cmFreeLook.m_Orbits[i].m_Radius = m_originalOrbits[i].m_Radius * scale;
                }
            }
        }
Пример #8
0
        /// <summary>Called by CinemachineCore at designated update time
        /// so the vcam can position itself and track its targets.  All 3 child rigs are updated,
        /// and a blend calculated, depending on the value of the Y axis.</summary>
        /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
        /// <param name="deltaTime">Delta time for time-based effects (ignore if less than 0)</param>
        override public void UpdateCameraState(Vector3 worldUp, float deltaTime)
        {
            //UnityEngine.Profiling.Profiler.BeginSample("CinemachineFreeLook.UpdateCameraState");
            if (!PreviousStateIsValid)
            {
                deltaTime = -1;
            }

            UpdateRigCache();

            // Reset the base camera state, in case the game object got moved in the editor
            if (deltaTime < 0)
            {
                m_State = PullStateFromVirtualCamera(worldUp); // Not in gameplay
            }
            // Update the current state by invoking the component pipeline
            m_State = CalculateNewState(worldUp, deltaTime);

            // Push the raw position back to the game object's transform, so it
            // moves along with the camera.  Leave the orientation alone, because it
            // screws up camera dragging when there is a LookAt behaviour.
            if (Follow != null)
            {
                Vector3 delta = State.RawPosition - transform.position;
                transform.position            = State.RawPosition;
                m_Rigs[0].transform.position -= delta;
                m_Rigs[1].transform.position -= delta;
                m_Rigs[2].transform.position -= delta;
            }

            PreviousStateIsValid = true;

            // Set up for next frame
            bool activeCam = (deltaTime >= 0) || CinemachineCore.Instance.IsLive(this);

            if (activeCam)
            {
                m_YAxis.Update(deltaTime);
            }

            PushSettingsToRigs();

            //UnityEngine.Profiling.Profiler.EndSample();
        }
Пример #9
0
    public float TestRecentering(float minValue, float maxValue, bool wrap,
                                 float maxSpeed, float accelTime, float decelTime, bool invert, float axisValue,
                                 bool enabled, float recenteringTime)
    {
        var axisState = new AxisState(minValue, maxValue, false, false, maxSpeed, accelTime, decelTime, null, invert);

        axisState.SetInputAxisProvider(0, new TestAxisProvider(axisValue));
        axisState.Validate();

        var success = axisState.Update(1.0f);

        Assert.IsTrue(success, "Update had no effect");

        var recentering = new AxisState.Recentering(enabled, 0.0f, recenteringTime);

        recentering.DoRecentering(ref axisState, 10.0f, 0.0f);

        return(axisState.Value < Cinemachine.Utility.UnityVectorExtensions.Epsilon ? 0f : axisState.Value);
    }
Пример #10
0
    private void ProcessInput()
    {
        movement.Move(moveAxes.x, moveAxes.y);
        axis1.m_InputAxisValue = cameraAxes.y;
        axis2.Value            = Quaternion.Lerp(Quaternion.Euler(0, axis2.Value, 0), Quaternion.Euler(0, cameraAxes.x * 2, 0), velocidadDeRotacion * Time.deltaTime).eulerAngles.y;
        axis1.Update(Time.deltaTime);


        if (jump)
        {
            movement.Jump();
        }
        if (dash)
        {
            movement.Dash();
        }
        if (special)
        {
            movement.Special();
        }
    }
Пример #11
0
        /// <summary>Applies the axis values and orients the camera accordingly</summary>
        /// <param name="curState">The current camera state</param>
        /// <param name="deltaTime">Used for calculating damping.  Not used.</param>
        public override void MutateCameraState(ref CameraState curState, float deltaTime)
        {
            if (!IsValid)
            {
                return;
            }

            //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePOV.MutateCameraState");

            // Only read joystick when game is playing
            if (deltaTime >= 0 || CinemachineCore.Instance.IsLive(VirtualCamera))
            {
                m_HorizontalAxis.Update(deltaTime);
                m_VerticalAxis.Update(deltaTime);
            }
            Quaternion rot = Quaternion.Euler(m_VerticalAxis.Value, m_HorizontalAxis.Value, 0);

            rot = rot * Quaternion.FromToRotation(Vector3.up, curState.ReferenceUp);
            curState.OrientationCorrection = curState.OrientationCorrection * rot;

            //UnityEngine.Profiling.Profiler.EndSample();
        }
Пример #12
0
    void Update()
    {
        //入力を取得
        var inputX    = Input.GetAxis("Horizontal");
        var inputY    = Input.GetAxis("Vertical");
        var leftStick = new Vector3(inputX, 0, inputY).normalized;

        Horizontal.Update(Time.deltaTime);
        Vertical.Update(Time.deltaTime);

        //移動速度を計算
        var velocity = speed * leftStick;

        //向きを更新
        var horizontalRotation = Quaternion.AngleAxis(Horizontal.Value, Vector3.up);
        var verticalRotation   = Quaternion.AngleAxis(Vertical.Value, Vector3.right);

        transform.rotation = horizontalRotation;
        eye.localRotation  = verticalRotation;

        //Animatorに反映
        animator.SetFloat(hashFront, velocity.z, 0.1f, Time.deltaTime);
        animator.SetFloat(hashSide, velocity.x, 0.1f, Time.deltaTime);
    }
        /// <summary>
        /// Update the X axis and calculate the heading.  This can be called by a delegate
        /// with a custom axis.
        /// <param name="deltaTime">Used for damping.  If less than 0, no damping is done.</param>
        /// <param name="up">World Up, set by the CinemachineBrain</param>
        /// <param name="axis"></param>
        /// <returns>Axis value</returns>
        /// </summary>
        public float UpdateHeading(float deltaTime, Vector3 up, ref AxisState axis)
        {
            // Only read joystick when game is playing
            if (deltaTime >= 0 || CinemachineCore.Instance.IsLive(VirtualCamera))
            {
                bool xAxisInput = false;
                xAxisInput |= axis.Update(deltaTime);
                if (xAxisInput)
                {
                    mLastHeadingAxisInputTime   = Time.time;
                    mHeadingRecenteringVelocity = 0;
                }
            }
            float targetHeading = GetTargetHeading(axis.Value, GetReferenceOrientation(up), deltaTime);

            if (deltaTime < 0)
            {
                mHeadingRecenteringVelocity = 0;
                if (m_RecenterToTargetHeading.m_enabled)
                {
                    axis.Value = targetHeading;
                }
            }
            else
            {
                // Recentering
                if (m_BindingMode != BindingMode.SimpleFollowWithWorldUp &&
                    m_RecenterToTargetHeading.m_enabled &&
                    (Time.time > (mLastHeadingAxisInputTime + m_RecenterToTargetHeading.m_RecenterWaitTime)))
                {
                    // Scale value determined heuristically, to account for accel/decel
                    float recenterTime = m_RecenterToTargetHeading.m_RecenteringTime / 3f;
                    if (recenterTime <= deltaTime)
                    {
                        axis.Value = targetHeading;
                    }
                    else
                    {
                        float headingError    = Mathf.DeltaAngle(axis.Value, targetHeading);
                        float absHeadingError = Mathf.Abs(headingError);
                        if (absHeadingError < UnityVectorExtensions.Epsilon)
                        {
                            axis.Value = targetHeading;
                            mHeadingRecenteringVelocity = 0;
                        }
                        else
                        {
                            float scale           = deltaTime / recenterTime;
                            float desiredVelocity = Mathf.Sign(headingError)
                                                    * Mathf.Min(absHeadingError, absHeadingError * scale);
                            // Accelerate to the desired velocity
                            float accel = desiredVelocity - mHeadingRecenteringVelocity;
                            if ((desiredVelocity < 0 && accel < 0) || (desiredVelocity > 0 && accel > 0))
                            {
                                desiredVelocity = mHeadingRecenteringVelocity + desiredVelocity * scale;
                            }
                            axis.Value += desiredVelocity;
                            mHeadingRecenteringVelocity = desiredVelocity;
                        }
                    }
                }
            }
            float finalHeading = axis.Value;

            if (m_BindingMode == BindingMode.SimpleFollowWithWorldUp)
            {
                axis.Value = 0;
            }
            return(finalHeading);
        }