Recentering
Whenever you start the application in Holoboard, the user's head orientation with respect to the Unity Space is not clearly defined. We use Recentering to allow the user to realign or recenter his orientation so that the unity coordinate system matches with the user's.
In this section, we will describe the simplest way to recenter using the Holoboard Controller.
Create a Game Object that you want to the user to recenter to. The user will directly face this GameObject when recentering in performed.
Drag and drop the GameObject from the scene hierarchy along which the user's head orientation will be recentered to, to the Recenter Point point in the inspector of the ARCamera - Basic prefab as shown below.
Alternatively, you can also set the recenter GameObject during runtime. See the script below.
Create and Add a new script on any GameObject in the scene.
- For example, let's create a new script called Recenter.
- The function of this script will be to recenter the user's head rotation to the RecenterTransform transform whenever the user presses the HOME_BTN.
- Copy paste the following code snippet to Recenter script.
using UnityEngine;
using TesseractBasic;
public class Recenter : MonoBehaviour {
[SerializeField]
//Transform to which the user's head will be recentered to.
private Transform RecenterTransform;
void Start ()
{
//Set the Recenter Point of the ARCamera class
if (RecenterTransform != null)
ARCamera.Instance.SetRecenterPoint (RecenterTransform);
//Subscribe to the Global Callback OnButtonSingleClickConfirm
ControllerCallbacks.OnButtonSingleClickConfirm += RecenterClick;
}
//This function will be called whenever the OnButtonSingleClickConfirm event will be invoked.
//The arugment <button> tells us which button was clicked.
void RecenterClick (CONTROLLER_BUTTON button)
{
//Check if the button click was the HOME_BTN
if (button == CONTROLLER_BUTTON.HOME_BTN) {
//Recenter the user's head rotation to RecenterTransform
ARCamera.Instance.Recenter ();
}
}
void OnDestroy ()
{
//Subscribe to the Global Callback OnButtonSingleClickConfirm to prevent future errors.
ControllerCallbacks.OnButtonSingleClickConfirm -= RecenterClick;
}
}
This concludes the basics of using Holoboard SDK. Do checkout the examples to learn more!