/// <summary>
/// 获取BoxCollider范围内的随机点
/// </summary>
/// <param name="boxcollider"></param>
/// <returns></returns>
public static Vector3 GetBoxColliderRandomPos(this BoxCollider boxcollider)
{
Vector3 pos;
pos.x = boxcollider.center.x + Random.Range(-boxcollider.size.x, boxcollider.size.x) * 0.5f;
pos.y = boxcollider.center.y + Random.Range(-boxcollider.size.y, boxcollider.size.y) * 0.5f;
pos.z = boxcollider.center.z + Random.Range(-boxcollider.size.z, boxcollider.size.z) * 0.5f;
pos = boxcollider.transform.TransformPoint(pos);
return pos;
}
Unity BoxCollider范围内随机点
最新推荐文章于 2023-12-20 15:19:01 发布
关键词由CSDN通过智能技术生成