Skip to content

Commit

Permalink
Use if for readability instead of switch with 2 cases
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpach committed Oct 18, 2018
1 parent c68be04 commit 11a6d84
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions Mirror/Runtime/NetworkTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -913,21 +913,19 @@ void FixedUpdateServer()

bool CheckVelocityChanged()
{
switch (transformSyncMode)
if (transformSyncMode == TransformSyncMode.SyncRigidbody2D)
{
case TransformSyncMode.SyncRigidbody2D:
if (m_RigidBody2D && m_VelocityThreshold > 0)
{
return Mathf.Abs(m_RigidBody2D.velocity.sqrMagnitude - m_PrevVelocity) >= m_VelocityThreshold;
}
break;

case TransformSyncMode.SyncRigidbody3D:
if (m_RigidBody3D && m_VelocityThreshold > 0)
{
return Mathf.Abs(m_RigidBody3D.velocity.sqrMagnitude - m_PrevVelocity) >= m_VelocityThreshold;
}
break;
if (m_RigidBody2D && m_VelocityThreshold > 0)
{
return Mathf.Abs(m_RigidBody2D.velocity.sqrMagnitude - m_PrevVelocity) >= m_VelocityThreshold;
}
}
else if (transformSyncMode == TransformSyncMode.SyncRigidbody3D)
{
if (m_RigidBody3D && m_VelocityThreshold > 0)
{
return Mathf.Abs(m_RigidBody3D.velocity.sqrMagnitude - m_PrevVelocity) >= m_VelocityThreshold;
}
}
return false;
}
Expand Down

0 comments on commit 11a6d84

Please sign in to comment.