I am trying to cast 32 rays equally around a 360 degree radius. I am terrible with trig and can’t seem to figure out what I’m doing wrong. My code is as follows:
for (float angle = 0; angle <= 360; angle += 11.25)
{
int dist = 0;
double xFloat = GameController.Instance.PlayerInstance.transform.position.x;
double yFloat = GameController.Instance.PlayerInstance.transform.position.y;
double xMove = Math.Cos(angle);
double yMove = Math.Sin(angle);
while (true)
{
xFloat = xFloat + xMove;
yFloat = yFloat + yMove;
dist++;
Debug.DrawRay(GameController.Instance.PlayerInstance.transform.position,
GameController.Instance.PlayerInstance.transform.position - new Vector3((float)xFloat, (float)yFloat), Color.green);
break;
}
}
As you can see the rays are not shooting out on an equal angle. Any ideas? ![]()
