private void Snap(Vector3 position, Quaternion rotation)
 {
     if (CacheNavMeshAgent != null)
     {
         CacheNavMeshAgent.Warp(position);
         syncingTransform.rotation = rotation;
     }
     else if (CacheRigidbody3D != null && !CacheRigidbody3D.isKinematic)
     {
         syncingTransform.position = position;
         syncingTransform.rotation = rotation;
         CacheRigidbody3D.position = position;
         CacheRigidbody3D.rotation = rotation;
     }
     else if (CacheRigidbody2D != null && !CacheRigidbody2D.isKinematic)
     {
         syncingTransform.position = position;
         syncingTransform.rotation = rotation;
         CacheRigidbody2D.position = position;
         CacheRigidbody2D.rotation = rotation.eulerAngles.z;
     }
     else
     {
         syncingTransform.position = position;
         syncingTransform.rotation = rotation;
     }
 }
Пример #2
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;
     }
 }
 public void SetWanderDestination(float time, Vector3 destination)
 {
     setDestinationTime = time;
     isWandering        = true;
     ResumeMove(ObstacleAvoidanceType.NoObstacleAvoidance);
     CacheNavMeshAgent.speed = monsterDatabase.wanderMoveSpeed;
     CacheNavMeshAgent.SetDestination(destination);
     wanderDestination = destination;
 }
 public void SetDestination(float time, Vector3 destination)
 {
     setDestinationTime = time;
     isWandering        = false;
     ResumeMove(ObstacleAvoidanceType.GoodQualityObstacleAvoidance);
     CacheNavMeshAgent.speed = gameplayRule.GetMoveSpeed(CacheMonsterCharacterEntity);
     CacheNavMeshAgent.SetDestination(destination);
     oldDestination = destination;
 }
        public void SetSpawnArea(Vector3 spawnPosition, out Vector3 resultSpawnPosition)
        {
            resultSpawnPosition = spawnPosition;
            NavMeshHit navHit;

            if (NavMesh.SamplePosition(spawnPosition, out navHit, 100f, -1))
            {
                resultSpawnPosition = navHit.position;
                CacheNavMeshAgent.Warp(spawnPosition);
            }
        }
 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;
     }
 }
Пример #7
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;
     }
 }