//控制射击的方向
public void ShootDirection()
{
Vector3 worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); //获取鼠标的世界坐标
worldPoint = new Vector3(worldPoint.x, worldPoint.y, transform.position.z); //设置世界坐标
Vector3 pos = worldPoint - transform.position; //获取向量坐标的差值的向量
float angle = Vector3.Angle(Vector3.up, pos); //设置偏移角度
if (worldPoint.x>transform.position.x)
{
angle = -angle;
}
transform.eulerAngles = new Vector3(0, 0, angle); //使用欧拉角变化其位置方向
}

相关文章:

  • 2021-10-23
  • 2021-11-04
  • 2022-12-23
  • 2021-09-09
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2021-10-25
  • 2021-10-24
  • 2022-01-01
相关资源
相似解决方案