Beispiel #1
0
        private void OnDrawGizmosSelected()
        {
            // gravity opposite direction
            if (_enemyRigidbody != null)
            {
                Gizmos.color = Color.cyan;
                DrawArrow.ForGizmo(transform.position, _enemyRigidbody.velocity);
            }

            var targetNormal = (transform.position - Planet.position).normalized;
            var capsuleB     = Quaternion.FromToRotation(Vector3.up, targetNormal) *
                               CapsuleBegin;
            var capsuleE = Quaternion.FromToRotation(Vector3.up, targetNormal) *
                           CapsuleEnd;

            // bomb player detection range
            DebugExtension.DrawCapsule(transform.position + capsuleB,
                                       transform.position + capsuleE,
                                       _isPlayerInRange ? Color.red : Color.gray, CapsuleRadius);

            if (!_isPlayerInRange)
            {
                return;
            }

            Gizmos.color = Color.red;
            Gizmos.DrawLine(transform.position,
                            transform.position +
                            (Player.position - transform.position).normalized *
                            _distanceToPlayer);
        }
Beispiel #2
0
        public override void OnDrawGizmos(bool isGizmo, Color color)
        {
#if UNITY_EDITOR
            DebugExtension.DrawCapsule(
                a.ToVector3() - (_hDir.normalized.ToVector3() * r.ToFloat()),
                b.ToVector3() + (_hDir.normalized.ToVector3() * r.ToFloat()),
                color,
                r.ToFloat());
#endif
        }
Beispiel #3
0
    private void DrawCapsule()
    {
        float halfLength = CollisionInfo.CollisionInfoDefinition.Length / 2.0f;
        float radius     = CollisionInfo.CollisionInfoDefinition.Radius;

        Vector3 up   = transform.up;
        Vector3 pos  = transform.position;
        Vector3 to   = pos + (up * (halfLength + radius));
        Vector3 from = pos - (up * (halfLength + radius));

        DebugExtension.DrawCapsule(to, from, Gizmos.color, CollisionInfo.CollisionInfoDefinition.Radius);
    }
Beispiel #4
0
    void OnDrawGizmosSelected()
    {
        //Calculer le point d'origine du ray
        Vector3 boundsMax = GetComponent <Collider>().bounds.max;

        boundsMax.y = turret.transform.position.y;
        boundsMax   = boundsMax - turret.transform.position;
        Vector3 rayOrigin    = turret.transform.position + (targetDirection.normalized * boundsMax.magnitude);
        float   viewDistance = valueScript.viewMinDistance - Vector3.Distance(turret.transform.position, rayOrigin);

        DebugExtension.DrawCapsule(rayOrigin, rayOrigin, Color.yellow, viewDistance);
    }
Beispiel #5
0
    // Draw Gizmos so we can visualize what we are doing
    private void OnDrawGizmos()
    {
        Gizmos.color = boundingBoxColour;
        Vector3 center = new Vector3(transform.position.x, transform.position.y + HalfHeight, transform.position.z); // Offset the center so the gameobjects pivot is on the bottom
        Vector3 size   = new Vector3(boxLength, boxHeight, boxWidth);                                                // Create size for bounding box

        Gizmos.DrawWireCube(center, size);                                                                           // Draw the bounding box

        foreach (Vector3 point in spawnPoints)
        {
            // Custom Gizmos, allows us to draw a capsule
            DebugExtension.DrawCapsule(point, spawnerRadius, boxHeight, spawnerColour);
        }
    }
Beispiel #6
0
        /// <summary>
        /// Draws a wireframe capsule given a <see cref="CapsuleCollider"/>.
        /// </summary>
        public static void DrawCapsuleCollider(CapsuleCollider capsule, Color color)
        {
            Vector3 direction = Vector3.zero;

            switch (capsule.direction)
            {
            case 0: direction = Vector3.right; break;

            case 1: direction = Vector3.up; break;

            case 2: direction = Vector3.forward; break;
            }
            direction *= capsule.height * 0.5f;
            Vector3 center = capsule.bounds.center;

            DebugExtension.DrawCapsule(center - direction, center + direction, color, capsule.radius);
        }
    void OnDrawGizmosSelected()
    {
        float   radius = this.radius;
        Vector3 pos    = new Vector3(this.transform.position.x + capsuleColliderCenter.x, this.transform.position.y + capsuleColliderCenter.y, this.transform.position.z + capsuleColliderCenter.z);

        Gizmos.color = Color.yellow;
        //Gizmos.DrawWireSphere(pos, radius);
        //Gizmos.DrawWireSphere(pos + new Vector3(0,1,0), radius);
        DebugExtension.DrawCapsule(pos - new Vector3(0, height / 2, 0), pos + new Vector3(0, height / 2, 0), Color.blue, radius);
        if (footCollider != null)
        {
            float   radiusCheck = footCollider.radius * 0.95f;
            Vector3 posCheck    = new Vector3(this.transform.position.x + capsuleColliderCenter.x, this.transform.position.y + capsuleColliderCenter.y, this.transform.position.z + capsuleColliderCenter.z) - Vector3.up * (radiusCheck * 0.1f);
            Gizmos.color = Color.red;
            //Gizmos.DrawSphere(posCheck, radiusCheck);
            DebugExtension.DrawCapsule(posCheck - new Vector3(0, height / 2, 0), posCheck + new Vector3(0, height / 2, 0), Color.red, radiusCheck);
        }
    }
Beispiel #8
0
    void OnDrawGizmosSelected()
    {
        Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
        Gizmos.color  = color;

        switch (type)
        {
        case CustomLightType.Box:
            Gizmos.DrawWireCube(Vector3.zero, 2f * boxRadius);
            Gizmos.DrawWireCube(Vector3.zero, 2f * innerBoxRadius);
            break;

        case CustomLightType.Capsule:
            DebugExtension.DrawCapsule(new Vector3(0f, 0f, -capsuleLength * .5f - capsuleRadius), new Vector3(0f, 0f, capsuleLength * .5f + capsuleRadius), capsuleRadius);
            Gizmos.DrawLine(new Vector3(0f, 0f, -capsuleLength * .5f), new Vector3(0f, 0f, capsuleLength * .5f));
            break;
        }

        Gizmos.matrix = Matrix4x4.identity;
    }
Beispiel #9
0
 void OnDrawGizmos()
 {
     if (debugPoint)
     {
         DebugExtension.DrawPoint(debugPoint_Position, debugPoint_Color, debugPoint_Scale);
     }
     if (debugBounds)
     {
         DebugExtension.DrawBounds(new Bounds(new Vector3(10, 0, 0), debugBounds_Size), debugBounds_Color);
     }
     if (debugCircle)
     {
         DebugExtension.DrawCircle(new Vector3(20, 0, 0), debugCircle_Up, debugCircle_Color, debugCircle_Radius);
     }
     if (debugWireSphere)
     {
         Gizmos.color = debugWireSphere_Color;
         Gizmos.DrawWireSphere(new Vector3(30, 0, 0), debugWireSphere_Radius);
     }
     if (debugCylinder)
     {
         DebugExtension.DrawCylinder(new Vector3(40, 0, 0), debugCylinder_End, debugCylinder_Color, debugCylinder_Radius);
     }
     if (debugCone)
     {
         DebugExtension.DrawCone(new Vector3(50, 0, 0), debugCone_Direction, debugCone_Color, debugCone_Angle);
     }
     if (debugArrow)
     {
         DebugExtension.DrawArrow(new Vector3(60, 0, 0), debugArrow_Direction, debugArrow_Color);
     }
     if (debugCapsule)
     {
         DebugExtension.DrawCapsule(new Vector3(70, 0, 0), debugCapsule_End, debugCapsule_Color, debugCapsule_Radius);
     }
     if (debugCapsule)
     {
         DebugExtension.DrawCapsule(new Vector3(80, 0, 0), 20, debugCapsule_Radius);
     }
 }
Beispiel #10
0
    /// <summary>
    /// Draws a path on the editor
    /// </summary>
    /// <param name="path"> Supplying no path will just render the editor's debug path</param>
    public void drawRichochetPath(RicochetPath path = null)
    {
        if (path == null)
        {
            if (editorRicochetPath == null)
            {
                setEditorPath();
            }
            path = editorRicochetPath;
        }
        for (int i = 0; i < path.ricochetPositions.Count - 1; i++)
        {
            //I'm drawing based off the objrct positond, but since the object has a raduis I have to extend the drawing to account for its volume.
            Vector3 segmentVector = (-path.ricochetPositions[i] + path.ricochetPositions[i + 1]).normalized;
            DebugExtension.DrawCapsule(path.ricochetPositions[i] + -segmentVector * ricochetObjectRadius, path.ricochetPositions[i + 1] + segmentVector * ricochetObjectRadius, getDrawingColor(path.mode), _ricochetObjectRadius);
        }

        foreach (Vector3 point in path.ricochetPositions)
        {
            DebugExtension.DrawPoint(point, Color.blue, 1);
        }
    }
        void OnDrawGizmos()
        {
            if (!drawGizmos)
            {
                return;
            }

            if (boneCols == null)
            {
                boneCols = new CapsuleCollider[bones.Length];
            }
            for (int b = 0; b < bones.Length; ++b)
            {
                if (bones [b] == null)
                {
                    continue;
                }
                if (boneCols [b] == null)
                {
                    boneCols [b] = bones [b].GetComponent <CapsuleCollider> ();
                }
                else
                {
                    Vector3 direction = bones[b].forward;
                    switch (boneCols [b].direction)
                    {
                    case 0: direction = bones [b].right; break;

                    case 1: direction = bones [b].up; break;

                    case 2: direction = bones [b].forward; break;
                    }
                    Vector3 center = boneCols [b].center + bones [b].transform.position;
                    Vector3 half   = direction * boneCols [b].height * 0.5f;
                    DebugExtension.DrawCapsule(center + half, center - half, Color.red, boneCols [b].radius);
                }
            }
        }
Beispiel #12
0
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.red;
        DebugExtension.DrawCapsule((Vector3)BodyPosition + 0.5f * BodySize.y * Vector3.down,
                                   (Vector3)BodyPosition + 0.5f * BodySize.y * Vector3.up, Gizmos.color, 0.5f * BodySize.x);

        var top = BodyPosition + Vector2.up * (0.5f * BodySize.y + RayCastEpsilon);

        Gizmos.DrawLine(BodyPosition, top);
        Gizmos.DrawLine(top + 0.1f * Vector2.left, top + 0.1f * Vector2.right);

        var front = BodyPosition + Vector2.right * Direction * (0.5f * BodySize.x + WallStickiness);

        Gizmos.DrawLine(BodyPosition, front);
        Gizmos.DrawLine(front + 0.1f * Vector2.up, front + 0.1f * Vector2.down);
        Gizmos.DrawLine(front + 0.1f * Vector2.up, front + 0.1f * Vector2.down);

        var backBottom  = BodyPosition - 0.25f * BodySize.x * Direction * Vector2.right;
        var frontBottom = BodyPosition + 0.25f * BodySize.x * Direction * Vector2.right;
        var down        = Vector2.down * (0.5f * BodySize.y + RailStickiness);

        Gizmos.DrawLine(backBottom, backBottom + down);
        Gizmos.DrawLine(frontBottom, frontBottom + down);
        Gizmos.DrawLine(backBottom + down + 0.1f * Vector2.left, backBottom + down + 0.1f * Vector2.right);
        Gizmos.DrawLine(frontBottom + down + 0.1f * Vector2.left, frontBottom + down + 0.1f * Vector2.right);

        if (_previousPositions.Count > 1)
        {
            var prev = _previousPositions.Peek();
            foreach (var pos in _previousPositions.Skip(1))
            {
                Gizmos.DrawLine(prev, pos);
                prev = pos;
            }
        }
    }
 /// <summary>
 /// You can override drawing method for yout needs
 /// </summary>
 protected override void Draw()
 {
     DebugExtension.DrawCapsule(MultipliedStartPosition, MultipliedEndPosition, Color, Radius);
 }
 public void Draw(Color color)
 {
     DebugExtension.DrawCapsule(MultipliedStartPosition, MultipliedEndPosition, color, Radius);
 }
    void OnDrawGizmos()
    {
        _colliders = IncludeCollidersInChildren ? GetComponentsInChildren <Collider>() : GetComponents <Collider>();

        if (_colliders == null || _colliders.Length == 0)
        {
            return;
        }

        if (AlwaysShowCollider)
        {
            _prevColor   = Gizmos.color;
            Gizmos.color = GizmoColor;

            Collider _temp;
            for (int i = 0; i < _colliders.Length; i++)
            {
                _temp = _colliders[i];
                if (!_temp.enabled)
                {
                    continue;
                }
                if ((_boxTemp = _temp as BoxCollider) != null)
                {
                    Matrix4x4 oldGizmosMatrix = Gizmos.matrix;

                    Gizmos.matrix = Matrix4x4.TRS(_boxTemp.transform.TransformPoint(_boxTemp.center), _boxTemp.transform.rotation, _boxTemp.transform.lossyScale);
                    Gizmos.DrawWireCube(Vector3.zero, _boxTemp.size);

                    Gizmos.matrix = oldGizmosMatrix;
                }
                else if ((_sphereTemp = _temp as SphereCollider) != null)
                {
                    Matrix4x4 oldGizmosMatrix = Gizmos.matrix;

                    Gizmos.matrix = Matrix4x4.TRS(_sphereTemp.transform.TransformPoint(_sphereTemp.center), _sphereTemp.transform.rotation, Vector3.one *
                                                  Mathf.Max(Mathf.Abs(_sphereTemp.transform.lossyScale.x), Mathf.Max(Mathf.Abs(_sphereTemp.transform.lossyScale.y), Mathf.Abs(_sphereTemp.transform.lossyScale.z))));
                    Gizmos.DrawWireSphere(Vector3.zero, _sphereTemp.radius);

                    Gizmos.matrix = oldGizmosMatrix;
                }
                else if ((_capsuleTemp = _temp as CapsuleCollider) != null)
                {
                    Vector3 ls = _capsuleTemp.transform.lossyScale;
                    var     centerHalfScale = new Vector3(_capsuleTemp.center.x * ls.x, _capsuleTemp.center.y * ls.y, _capsuleTemp.center.z * ls.z);
                    float   halfHeight      = _capsuleTemp.height * Mathf.Abs(ls.y) * 0.5f;
                    var     directionVector = _capsuleTemp.transform.up;

                    // direction == 0 is the X-axis
                    if (_capsuleTemp.direction == 0)
                    {
                        directionVector = (Quaternion.AngleAxis(90, Vector3.forward) * Vector3.up);
                    }
                    // direction == 1 is the Y-axis
                    else if (_capsuleTemp.direction == 1)
                    {
                        directionVector = (Quaternion.AngleAxis(90, Vector3.up) * Vector3.up);
                    }
                    // direction == 2 is the Z-axis
                    else if (_capsuleTemp.direction == 2)
                    {
                        directionVector = (Quaternion.AngleAxis(90, Vector3.right) * Vector3.up);
                    }

                    Matrix4x4 oldGizmosMatrix = Gizmos.matrix;
                    Gizmos.matrix = Matrix4x4.TRS(_capsuleTemp.transform.position, _capsuleTemp.transform.rotation, Vector3.one);
                    Vector3 capsuleBoundsStart = centerHalfScale + directionVector * halfHeight;
                    Vector3 capsuleBoundsEnd   = centerHalfScale - directionVector * halfHeight;

                    DebugExtension.DrawCapsule(capsuleBoundsStart, capsuleBoundsEnd, GizmoColor,
                                               _capsuleTemp.radius * Mathf.Max(Mathf.Abs(ls.x), Mathf.Abs(ls.z)) // scale radius by: capsule radius, multiplied by the largest of X and Z lossyScales
                                               );

                    Gizmos.matrix = oldGizmosMatrix;
                }
            }

            Gizmos.color = _prevColor;
        }
    }