Rotating a sphere with VRTK_Pointer
I am trying to rotate a sphere using VRTK_Pointer
. The idea is that the sphere rotation will be controlled by the pointer. I am using the pointer to grab and move objects in my scene, but I also have a large and remote "globe" object that I want only to rotate when pointed at.
public class PointerRotate : MonoBehaviour
{
private VRTK_Pointer pointer;
void Start()
{
this.pointer = this.GetComponent<VRTK_Pointer>();
this.pointer.DestinationMarkerHover+=this.OnHover;
}
private void OnHover(object sender, DestinationMarkerEventArgs e)
{
e.target.LookAt(e.raycastHit.point);
}
}
The above kinda works, but since I am using LookAt
, it is always rotates according to the hit
position, so I cannot rotate to the "dark-side" of the globe. If this makes sense...
I guess I need to use Quaternion.LookRotation()
instead and to compensate the current rotation of the sphere, but I wasn't able to understand how.
Comment