2016-12-07 55 views
1

如何使用本地轴心点来旋转一个精灵?如何使用局部轴心点来旋转一个精灵?

这是我现在使用的代码,它工作正常,但对于本地中心点。

private Camera myCamera; 

void Start() { 

    myCamera = GameObject.FindObjectOfType<Camera>(); 
} 

void Update() { 

    Vector3 pos = myCamera.WorldToScreenPoint (transform.position); 
    Vector3 dir = Input.mousePosition - pos; 
    float angle = Mathf.Atan2 (dir.y, dir.x) * Mathf.Rad2Deg; 
    this.transform.localRotation = Quaternion.AngleAxis (angle, Vector3.forward); 
} 

}

回答