Closed alamboley closed 7 years ago
@alamboley I'd encourage you to look at the documentation for the Input module, but this should be pretty straightforward to convert.https://github.com/Microsoft/HoloToolkit-Unity/blob/master/Assets/HoloToolkit/Input/README.md
The rotation specific portion of the script you posted is using the "Navigation" gesture, so you need to implement the "INavigationHandler" interface. You can do something simple like this where you update the rotation factor inside of OnNavigationUpdated
and zero it out in OnNavigationCompleted
and OnNavigationCanceled
. You can then use this rotation factor in the Update function to perform the rotation. I'm not sure what frequency the navigation events come in, which is why I'm still rotating in the update function instead of per event.
Note, I haven't tested the following code, its mainly for illustration purposes.
public class RotateOnNavigate : MonoBehaviour, INavigationHandler
{
[Tooltip("Rotation max speed controls amount of rotation.")]
public float RotationSensitivity = 10.0f;
private Vector3 rotationFactor = Vector3.zero;
void INavigationHandler.OnNavigationStarted(NavigationEventData eventData)
{
}
void INavigationHandler.OnNavigationUpdated(NavigationEventData eventData)
{
rotationFactor.y = -eventData.CumulativeDelta.x * RotationSensitivity;
}
void INavigationHandler.OnNavigationCanceled(NavigationEventData eventData)
{
rotationFactor = Vector3.zero;
}
void INavigationHandler.OnNavigationCompleted(NavigationEventData eventData)
{
rotationFactor = Vector3.zero;
}
private void Update()
{
transform.Rotate(rotationFactor);
}
}
That's perfect, many thanks!
Hello there,
I played with Hololens lately, it's really nice :) I watched the tutorials from the Academy, however since HoloToolkit evolved I've some troubles to port old examples.
This code, from the academy, is just making a rotation on a object. How could I do the same with the latest HololensToolkit version?
Thanks for the help.