コード例 #1
0
        public void CalculatePositionIsDifferentFromOriginal()
        {
            CameraMovementBehaviourController movement =
                new CameraMovementBehaviourController(new Vector3(0, 10, 0), 0.5f);
            Vector3 currentPosition = new Vector3(10, 11, 5);
            Vector3 playerPosition  = new Vector3(11, 1, 4);
            float   deltaTime       = 0.01f;

            Vector3 newPosition = movement.CalculatePosition(currentPosition, playerPosition, deltaTime);

            Assert.AreNotEqual(currentPosition, newPosition);
        }
コード例 #2
0
        public void CalculatePositionNotTooFast()
        {
            CameraMovementBehaviourController movement =
                new CameraMovementBehaviourController(new Vector3(0, 10, 0), 0.5f);
            Vector3 currentPosition = new Vector3(0, 11, 0);
            Vector3 playerPosition  = new Vector3(0, 1, 2);
            float   deltaTime       = 0.01f;

            Vector3 newPosition = movement.CalculatePosition(currentPosition, playerPosition, deltaTime);

            Assert.IsTrue(newPosition.z < 2);
        }
コード例 #3
0
 private void LateUpdate()
 {
     // Moving in LateUpdate so the object we're following has already moved
     transform.position =
         _movement.CalculatePosition(transform.position, Player.transform.position, Time.deltaTime);
 }