Esempio n. 1
0
        private void FixedUpdateMotor()
        {
            var newPosition = _rb.position + Input * MoveSpeed * Time.fixedDeltaTime;

            if (PixelSnap)
            {
                newPosition = PixelPerfectClamp(newPosition, 128);
            }
            _rb.MovePosition(newPosition);

            if (CamBrain)
            {
                CamBrain.ManualUpdate();
            }

            if (Input == Vector2.zero)
            {
                _rb.MovePosition(newPosition.PixelPerfect());
            }
        }
        public IEnumerator CheckSmoothingTime()
        {
            m_Collider.m_SmoothingTime       = 1;
            m_Collider.m_Damping             = 0;
            m_Collider.m_DampingWhenOccluded = 0;
            var originalCamPosition = m_Vcam.State.FinalPosition;

            yield return(null);

            m_Brain.ManualUpdate();

            Assert.That(originalCamPosition, Is.EqualTo(m_Vcam.State.FinalPosition).Using(Vector3EqualityComparer.Instance));

            var obstacle = GameObject.CreatePrimitive(PrimitiveType.Cube);

            obstacle.transform.position = originalCamPosition; // place obstacle so that camera needs to move

            yield return(WaitForOnePhysicsFrame());

            m_Brain.ManualUpdate();

            // camera moved check
            Assert.That(originalCamPosition, !Is.EqualTo(m_Vcam.State.FinalPosition).Using(Vector3EqualityComparer.Instance));
            Assert.That(new Vector3(0, 0, -4.4f), Is.EqualTo(m_Vcam.State.FinalPosition).Using(Vector3EqualityComparer.Instance));

            UnityEngine.Object.Destroy(obstacle);

            // wait smoothing time and a frame so that camera move back to its original position
            var timerStart = CinemachineCore.CurrentTime;

            yield return(WaitForOnePhysicsFrame());

            do
            {
                m_Brain.ManualUpdate();
                yield return(null);
            } while ((CinemachineCore.CurrentTime - timerStart) < m_Collider.m_SmoothingTime);

            m_Brain.ManualUpdate();
            Assert.That(originalCamPosition, Is.EqualTo(m_Vcam.State.FinalPosition).Using(Vector3EqualityComparer.Instance));
        }