Esempio n. 1
0
        protected virtual void OnDrawGizmos()
        {
            Color col = Gizmos.color;

            Gizmos.color = new Color(1f, 0f, 0f, 0.5f);
            GizmosUtil.DrawCircle(transform.position, transform.rotation, engageDistance, teethCount);
            Gizmos.color = new Color(1f, 1f, 0f, 0.5f);
            GizmosUtil.DrawCircle(transform.position, transform.rotation, collisionDistance, teethCount);

            Gizmos.color = new Color(1f, 0.5f, 0f, 0.5f);
            float teethOffsetRadians = teethOffset * Mathf.PI / 180f;
            float rotationOffset     = transform.eulerAngles.z * Mathf.PI / 180f;

            for (int i = 0; i < teethCount; ++i)
            {
                float percent = (float)i / (float)teethCount;
                Gizmos.DrawLine(
                    transform.position + transform.rotation * new Vector3(Mathf.Cos(teethOffsetRadians + Mathf.PI * 2f * percent + rotationOffset) * collisionDistance,
                                                                          Mathf.Sin(teethOffsetRadians + Mathf.PI * 2f * percent + rotationOffset) * collisionDistance,
                                                                          0f),
                    transform.position + transform.rotation * new Vector3(Mathf.Cos(teethOffsetRadians + Mathf.PI * 2f * percent + rotationOffset) * engageDistance,
                                                                          Mathf.Sin(teethOffsetRadians + Mathf.PI * 2f * percent + rotationOffset) * engageDistance,
                                                                          0f));
            }

            Gizmos.color = col;
        }