public GameObject lookPoint;
public Vector3 direction;

void Start()
{

}

// Update is called once per frame
void Update()
{
direction = lookPoint.transform.position - transform.position;
if(Vector3.Angle(direction, transform.right) > 90f) // 目标点在右边
{
transform.Rotate(transform.forward, Vector3.Angle(direction, transform.up));
}
else // 目标点在左边
{
transform.Rotate(transform.forward, -Vector3.Angle(direction, transform.up));
}
}

posted on 2021-04-17 16:46  百晓灵狐  阅读(1497)  评论(0编辑  收藏  举报