private void Interpolate(Vector3 position, Quaternion rotation)
 {
     if (CacheNavMeshAgent != null)
     {
         CacheNavMeshAgent.Move(position - syncingTransform.position);
         syncingTransform.rotation = rotation;
     }
     else if (CacheCharacterController != null)
     {
         syncingTransform.position = position;
         syncingTransform.rotation = rotation;
     }
     else if (CacheRigidbody3D != null && !CacheRigidbody3D.isKinematic)
     {
         if (Vector3.Distance(position, CacheRigidbody3D.position) > 0f)
         {
             CacheRigidbody3D.MovePosition(position);
         }
         else
         {
             CacheRigidbody3D.velocity = Vector3.zero;
             CacheRigidbody3D.MovePosition(position);
         }
         syncingTransform.rotation = rotation;
     }
     else if (CacheRigidbody2D != null && !CacheRigidbody2D.isKinematic)
     {
         if (Vector2.Distance(position, CacheRigidbody2D.position) > 0f)
         {
             CacheRigidbody2D.MovePosition(position);
         }
         else
         {
             CacheRigidbody2D.velocity = Vector2.zero;
             CacheRigidbody2D.MovePosition(position);
         }
         syncingTransform.rotation = rotation;
     }
     else
     {
         syncingTransform.position = position;
         syncingTransform.rotation = rotation;
     }
 }
Beispiel #2
0
 private void Interpolate(Vector3 position, Quaternion rotation)
 {
     if (CacheNavMeshAgent != null)
     {
         CacheNavMeshAgent.Move(position - syncingTransform.position);
         syncingTransform.rotation = rotation;
     }
     else if (CacheCharacterController != null)
     {
         CacheCharacterController.Move(position - syncingTransform.position);
         syncingTransform.rotation = rotation;
     }
     else if (CacheRigidbody3D != null)
     {
         CacheRigidbody3D.MoveRotation(rotation);
         if (Vector3.Distance(position, CacheRigidbody3D.position) >= movementTheshold)
         {
             CacheRigidbody3D.MovePosition(position);
         }
         else
         {
             CacheRigidbody3D.velocity = Vector3.zero;
             CacheRigidbody3D.MovePosition(position);
         }
     }
     else if (CacheRigidbody2D != null)
     {
         CacheRigidbody2D.MoveRotation(rotation.eulerAngles.z);
         if (Vector2.Distance(position, CacheRigidbody2D.position) >= movementTheshold)
         {
             CacheRigidbody2D.MovePosition(position);
         }
         else
         {
             CacheRigidbody2D.velocity = Vector2.zero;
             CacheRigidbody2D.MovePosition(position);
         }
     }
     else
     {
         syncingTransform.position = position;
         syncingTransform.rotation = rotation;
     }
 }