public Vector3 leftTangent,rightTangent;//玩家的左右切点
public void PanDing(){
Vector3 playerToExplsion=this.transform.position-player.position;//玩家到爆炸点的向量
Vector3 playerToExplsionDir=playerToExplsion.normalized*radius;
//玩家指向爆炸点,长度为半径的向量
float angle =Mathf.Acos(radius/playerToExplsion.magnitude)*Mathf.Rad2Deg;
//获取将playerToExplsionDir旋转到切点的角度
leftTangent=player.position+Quaternion.Euler(0,-angle,0)*playerToExplsionDir;
//旋转-angle度,向量指向左切点
rightTangent=player.position+Quaternion.Euler(0,angle,0)*playerToExplsionDir;
//旋转angle度,向量指向右切点
}
unity在爆炸问题中,计算爆炸点与玩家的距离
最新推荐文章于 2023-09-05 14:24:10 发布