• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Apr 18th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1.
2.         CustomOBBCollider coll = (CustomOBBCollider)collider;
3.
4.         for (int i = 0; i < points.Length; i++)
5.         {
6.             Vector3 face = (new Vector2(transform.position.x, transform.position.y) + points[(i + 1) % points.Length]) -
7.                             (new Vector2(transform.position.x, transform.position.y) + points[i]);
8.
9.             Vector2 normal = Vector3.Cross(face, new Vector3(0, 0, 1)).normalized;
10.
11.             projectedPointsOwn.Clear();
12.             projectedPointsColl.Clear();
13.
14.             for (int j = 0; j < points.Length; j++)
15.             {
16.                 projectedPointsOwn.Add(Project(normal, new Vector2(transform.position.x, transform.position.y) + points[j]));
17.             }
18.
19.             for (int j = 0; j < coll.points.Length; j++)
20.             {
21.                 projectedPointsColl.Add(Project(normal, new Vector2(coll.transform.position.x, coll.transform.position.y) + coll.points[j]));
22.             }
23.
24.             minPoint = Vector2.positiveInfinity;
25.             maxPoint = Vector2.negativeInfinity;
26.
27.             for (int j = 0; j < projectedPointsOwn.Count; j++)
28.             {
29.                 if (projectedPointsOwn[j].x < minPoint.x)
30.                 {
31.                     minPoint.x = projectedPointsOwn[j].x;
32.                 }
33.                 if (projectedPointsOwn[j].y < minPoint.y)
34.                 {
35.                     minPoint.y = projectedPointsOwn[j].y;
36.                 }
37.
38.                 if (projectedPointsOwn[j].x > maxPoint.x)
39.                 {
40.                     maxPoint.x = projectedPointsOwn[j].x;
41.                 }
42.                 if (projectedPointsOwn[j].y > maxPoint.y)
43.                 {
44.                     maxPoint.y = projectedPointsOwn[j].y;
45.                 }
46.             }
47.
48.             bool didOverlap = false;
49.
50.             for (int j = 0; j < projectedPointsColl.Count; j++)
51.             {
52.                 if (projectedPointsColl[j].x < maxPoint.x && projectedPointsColl[j].x > minPoint.x &&
53.                     projectedPointsColl[j].y < maxPoint.y && projectedPointsColl[j].y > minPoint.y)
54.                 {
55.                     didOverlap = true;
56.
57.                     break;
58.                 }
59.             }
60.
61.             if (!didOverlap)
62.             {
63.                 return false;
64.             }
65.         }
66.         return true;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top