Esempio n. 1
0
 private void Snap(Vector3 position, Quaternion rotation)
 {
     if (CacheNavMeshAgent != null)
     {
         CacheNavMeshAgent.Warp(position);
         syncingTransform.rotation = rotation;
     }
     else if (CacheRigidbody3D != null)
     {
         if (CacheRigidbody3D.IsSleeping())
         {
             CacheRigidbody3D.WakeUp();
         }
         CacheRigidbody3D.position = position;
         CacheRigidbody3D.rotation = rotation;
     }
     else if (CacheRigidbody2D != null)
     {
         if (CacheRigidbody2D.IsSleeping())
         {
             CacheRigidbody2D.WakeUp();
         }
         CacheRigidbody2D.position = position;
         CacheRigidbody2D.rotation = rotation.eulerAngles.z;
     }
     else
     {
         syncingTransform.position = position;
         syncingTransform.rotation = rotation;
     }
 }
 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;
     }
 }
Esempio n. 3
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;
     }
 }