/// <summary>
    /// Draws debug information using gizmos.
    /// </summary>
    protected override void OnDrawGizmos()
    {
        if (Active && debug && Application.isPlaying)
        {
            Gizmos.color = Color.magenta;

            // Draw the see ahead vector
            Vector2 seeAhead = (Vector2)transform.position + manager.Direction * seeAheadDistance;
            GizmosExt.DrawArrow(transform.position, seeAhead);

            // Get the closest obstacle hit
            RaycastHit2D hit = RayCast(transform.position, manager.Direction, seeAheadDistance);
            if (hit.collider != null)
            {
                // Draw the point of collision with the obstacle
                Gizmos.DrawSphere(hit.point, 0.15f);

                // Draw the desired velocity
                Vector2 velocity = CalculateDesiredVelocity(Vector2.zero);

                Gizmos.color = Color.white;
                GizmosExt.DrawArrow(transform.position, (Vector2)transform.position + velocity);
            }
        }
    }
 /// <summary>
 /// Draws debug information using gizmos.
 /// </summary>
 protected virtual void OnDrawGizmos()
 {
     if (active && debug && Application.isPlaying)
     {
         Gizmos.color = Color.red;
         GizmosExt.DrawArrow(transform.position, (Vector2)transform.position + velocity);
     }
 }
    void OnDrawGizmos()
    {
        Gizmos.color = _ledgeFinderGizmoColor;

        Gizmos.DrawLine(transform.position, transform.position + _wallPlane.normal);
        Gizmos.DrawLine(wallFinderRay.origin, wallFinderRay.origin + 100f * wallFinderRay.direction);

        //if (WasWallFound) {
        GizmosExt.DrawWireCylinder(transform.position + LedgeCastHeight * transform.up, transform.position, LedgeCastRadius);
        GizmosExt.DrawWireDisc(_ledgePoint, _ledgeNormal, LedgeCastRadius);
        //}
    }
Exemple #4
0
    /// <summary>
    /// Draws debug and control information in the editor.
    /// </summary>
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.magenta;

        // Draw a rectangle around the bounds
        Rect bounds = GetBounds();
        Rect area   = new Rect(bounds.x, bounds.y, bounds.width, bounds.height);

        GizmosExt.DrawRectangle(area);

        // Draw each cell
        Vector2 value, start, end;
        Rect    cell = new Rect(0, 0, bounds.width / columns, bounds.height / rows);

        for (int r = 0; r < rows; r++)
        {
            cell.y = bounds.yMin + r * cell.height;
            for (int c = 0; c < columns; c++)
            {
                // Draw the cell rectangle
                cell.x = bounds.xMin + c * cell.width;
                GizmosExt.DrawRectangle(cell);

                // Draw the cell contents
                value = field[r * columns + c];
                if (value != Vector2.zero)
                {
                    value = value.normalized;
                    value = new Vector2(value.x * transform.localScale.x, value.y * transform.localScale.y);
                    start = cell.center - value / 3.5f;
                    end   = cell.center + value / 3.5f;
                    GizmosExt.DrawArrow(start, end);
                }
            }
        }
    }
 private void OnDrawGizmosSelected()
 {
     GizmosExt.DrawCube(transform.TransformPoint(bounds.center), bounds.size, transform.rotation);
 }