Skip to main content
Version: 4.55.1

Eye Tracking

The Eye Tracking effect allows you to track the position and rotation of the user’s eyes. The Eye Tracking effect uses the Head Binding component to change the transform of the object the component is on.

Create Eyeballs

You can add Eye Tracking by going to the Objects panel, pressing the + button > Eyeballs. This will add a Left Eye and Right Eye object, each with their own Head Binding component and their respective attach point.

Attaching Objects to the Eye

The Left Eye and Right Eye object will position and rotate themselves based on the user’s eye. You can add an object as a child of either object to have your object track the eye.

By Default, each eye will come with two objects: Sclera and Choroid. These objects are provided as an example and can be removed. The Sclera adds a reflective sphere around the Choroid. Both use the default PBR material.

Using the Eyeball Rotation Only

The Head Binding component will modify both the rotation and position of the object it is attached to. In some cases, you may only want to use the rotation and manually position the eyeball.

You can use the following script to copy the rotation from one object to another. Then, in the Inspector panel, you can select the object with the Head Binding component as the source, and the object you want to rotate with the eye as the target.

You can see an example of this in the Face Expressions Template.

// CopyRotation.js
// Version: 0.0.1
// Description: Copies rotation from one object to another
// @input SceneObject sourceObject
// @input SceneObject targetObject
var targetTransform;
var sourceTransform;
if (script.targetObject) {
targetTransform = script.targetObject.getTransform();
} else {
targetTransform = script.getSceneObject().getTransform();
}
if (script.sourceObject) {
sourceTransform = script.sourceObject.getTransform();
} else {
print('[CopyRotation] Source object is not set');
}
function onUpdate() {
if (sourceTransform) {
targetTransform.setWorldRotation(sourceTransform.getWorldRotation());
}
}
var updateEvent = script.createEvent('UpdateEvent');
updateEvent.bind(onUpdate);

Changing the Eye to Track

Like any object with the Head Binding component, you can change the Face Index field to change which face to track for the eyeballs. The first detected face is 0, the second face is 1, and so forth.

Was this page helpful?
Yes
No