Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 824 Bytes

File metadata and controls

50 lines (38 loc) · 824 Bytes

UEA0016: VectorMagnitudeIsSlow

Property Value
Id UEA0016
Category Performance
Severity Info

Example

Code with Diagnostic

using UnityEngine;

class C : MonoBehaviour
{
    public Transform other;
    private float farDistance = 5.0f;

    void Update()
    {
        if ((other.position - transform.position).magnitude > farDistance) 
        { 
             //OPTIMIZE THIS CALL BY USING sqrMagnitude
        }
    }
}

Code with Fix

using UnityEngine;

class C : MonoBehaviour
{
    public Transform other;
    private float farDistance = 5.0f;

    void Update()
    {
        if ((other.position - transform.position).sqrMagnitude > farDistance * farDistance) 
        { 

        }
    }
}