Ejemplo n.º 1
0
        /// <summary>
        /// Checks to see if 2 circles are colliding
        /// </summary>
        /// <param name="col1"></param>
        /// <param name="col2"></param>
        /// <returns></returns>
        public static bool IsCollidingCircles(CircleCollider col1, CircleCollider col2)
        {
            Vector2 v = col1.centre - col2.centre;

            if (v.Magnitude < col1.radius + col2.radius)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks to see if a polygon and a circle are colliding
        /// </summary>
        /// <param name="col1"></param>
        /// <param name="col2"></param>
        /// <returns></returns>
        public static bool IsCollidingPolygonCircle(PolygonCollider col1, CircleCollider col2)
        {
            List <Vector2> edges = new List <Vector2>();

            edges = CalculateEdges(col1.Vertices);
            for (int i = 0; i < edges.Count; i++)
            {
                if (Vector2.Distance(col2.centre, edges[i]) < col2.radius)
                {
                    return(true);
                }
            }
            return(false);
        }