I am attempting to create a 2D level in an enclosed circle. I also need to use raycasting as objects will hit this circle, however the default 2D colliders do not really support this. I am abit lost of how to solve this as the solution needs to be scripted, any ideas on a good way to solve this?
Another option: add the following script to the object with the edge collider and set the edges and radius (0.5 for edge-to-edge). I tested it with 120 edges.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InitInverted2DEdges : MonoBehaviour {
public int NumEdges;
public float Radius;
// Use this for initialization
void Start () {
EdgeCollider2D edgeCollider = GetComponent<EdgeCollider2D>();
Vector2[] points = new Vector2[NumEdges];
for (int i = 0; i < NumEdges; i++)
{
float angle = 2 * Mathf.PI * i / NumEdges;
float x = Radius * Mathf.Cos(angle);
float y = Radius * Mathf.Sin(angle);
points *= new Vector2(x, y);*
}
edgeCollider.points = points;
}
}