Rotation Code Optimization – Manual vs DOTween

This type of rotation animation is used across multiple objects in the game—from player turns to environmental elements and UI transitions. Because it runs frequently and across many instances, optimizing it early was critical for reducing CPU overhead, ensuring consistent frame times, and keeping GC allocations low—especially on mobile.

Before

Quaternion startRotation = player.transform.rotation;
Quaternion endRotation = Quaternion.Euler(0, targetYAngle, 0);
float elapsed = 0f;

while (elapsed < duration)
{
    elapsed += Time.deltaTime;
    player.transform.rotation = Quaternion.Slerp(startRotation, endRotation, elapsed / duration);
    yield return null;
}

After (with DOTween)

// we use DOTween for interpolation and easing
player.transform.DORotate(new Vector3(0, targetYAngle, 0), duration).SetEase(Ease.OutSine);
yield return player.transform
    .DORotate(new Vector3(0, targetYAngle, 0), 0)
    .WaitForCompletion();
Why this is better:
  • Reduced lines of code: From 9 lines to 2—cleaner and easier to maintain.
  • Improved performance: DOTween handles interpolation internally using optimized C# coroutines, avoiding extra GC pressure and CPU usage from per-frame math.
  • Smoother animation: Built-in easing like Ease.OutSine makes transitions feel natural without manual math.
  • GC friendly: No per-frame Quaternion recalculation or struct allocations—DOTween uses pooling and caching behind the scenes.

Progress Screenshots

Before – early art style
After – updated art style

I updated the art direction by replacing early placeholder assets with low‑poly models, giving the game a cleaner, more distinct visual style that enhances its looks.

Screenshots

Contact

Got any Suggestions or queries? Reach out or check out the game on Play Store.