如何围绕空间中的特定点旋转对象并将其指向光标?

时间:2016-02-16 19:35:22

标签: unity3d

我的目标是让this line围绕脸部旋转,同时每帧指向我的光标。 到目前为止我得到的是:

void Update () {
    float AngleOfMouse = GetAngle (MiddleOfTheFace.position);
    transform.RotateAround (MiddleOfTheFace.position, Vector3.back, AngleOfMouse);
}
void GetAngle(){
Vector2 MousePosition = Input.mousePosition;
    Vector3 ScreenPoint = Camera.main.WorldToScreenPoint(point);
    Vector2 BulletOffset = new Vector2(MousePosition.x - ScreenPoint.x, MousePosition.y - ScreenPoint.y);
    float Angle = Mathf.Atan2(BulletOffset.y, BulletOffset.x) * Mathf.Rad2Deg;
    return Angle;
}

但它只是非常快速地旋转,并且当它指向我的光标时不会停止。我没有接近这个权利吗?提前谢谢!

0 个答案:

没有答案