我将光线转换用作霰弹枪。我随机化每条光线的方向:
Vector3 direction = new Vector3 (UnityEngine.Random.Range (-splash, splash), UnityEngine.Random.Range (-splash, splash), 100);
最佳答案
圆上点的坐标可以这样计算 x = r*cos(a), y = r*sin(a)
。如果 r 是随机点,则点将位于半径为“splash”的圆内;
Vector3 direction = new Vector3( Random.Range(-splash,splash)*Mathf.Cos(Random.Range(0,2*Mathf.PI)),Random.Range(-splash,splash)*Mathf.Sin(Random.Range(0,2*Mathf.PI)),0 );
关于c# - Unity3d 霰弹枪锥形射击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32423241/