I took the challenge and build on it.
Unity doesn’t have a SqrDistance method so I took this chance to start building my own library for future games: Here’s a little extension for the Transform class that checks if it’s in range of another vector.
public static bool InRange(this Transform trans, Vector3 target, float range)
{
range = Mathf.Pow(range, 2);
float squareMagnitude = (trans.position - target).sqrMagnitude;
return squareMagnitude < range;
}
I’ll be adding more to this library as I progress through the course.