I wanted to illustrate the weapon range so it would be easier to verify that the follow target code was
working as intended. So I started with a simple sphere gizmo.
private void OnDrawGizmos()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, weaponRange);
}
Then I remembered something cool I saw in a tutorial project a while back (I think it was the 3D game kit) where they had a cone illustration for the weapon range. So I added an adjustable arc instead of the wire sphere.
private void OnDrawGizmos()
{
Vector3 left = Quaternion.AngleAxis(-weaponAngle / 2f, Vector3.up) * transform.forward;
Handles.color = new Color(1f, 0f, 0f, 0.1f);
Handles.DrawSolidArc(transform.position + Vector3.up, Vector3.up, left, weaponAngle, weaponRange);
Handles.color = Color.red;
Handles.DrawWireArc(transform.position + Vector3.up, Vector3.up, left, weaponAngle, weaponRange);
}
Don’t think I’ll have much use for the adjustable angle for now but it was fun to try. Will just leave it at 360 degrees for the time being.