I got an error saying ````UnityEngine.Mathf.Deg2Rad’ is inaccessible due to its protection levelon a line that says
float exitAngle = Mathf.Asin(Mathf.Deg2Rad(enteranceAngle) / targetProperties.nValue);```. Mathf.Deg2Rad is public according to the Unity API so I’m just wondering why I can’t seem to access it. Thanks in advance.
Mathf.DegToRad is a float, not a method/function:
Do:
entranceAngle * Mathf.Deg2Rad
(note the example in the documentation)
1 Like
I tried this :
At the top of the script :
public float deg = 30.0F;
Then inside the Start :
private void Start()
{
float rad = deg * Mathf.Deg2Rad;
float exitAngle = Mathf.Asin(rad / targetProperties.nValue);
}
Try :
float rad = enteranceAngle * Mathf.Deg2Rad;
float exitAngle = Mathf.Asin(rad/ targetProperties.nValue);
Or
float exitAngle = Mathf.Asin((enteranceAngle * Mathf.Deg2Rad) / targetProperties.nValue);
1 Like
Never mind lordofduct already answered.
Ah thank you both. For some reason I assumed Deg2Rad was a method.