Eye tracking: print Y rotation value

Options
Coral Orca
Coral Orca Posts: 6
edited July 2022 in Programming #1

Hello, I am trying to trigger an animation when the user looks to the right.
I am currently using the Face Expression template with the Copy Rotation script to figure things out and isolate the Y rotation value that should track if the user looks to the left or the right.
But I am not sure how to print the eye rotation value, and trigger an animation with "If Xrotation>n THEN play animation".
I would love to get a bit of help to show me the way! Thanks

Comments

  • Coral Orca
    Options

    OK I have added this line in the onUpdate function :

    function onUpdate() {
    if (sourceTransform) {
    targetTransform.setWorldRotation(script.sourceObject.getTransform().getWorldRotation());
    print (script.sourceObject.getTransform().getWorldRotation());
    }
    }

    which gives me something like this

    10:26:40 [Scripts/CopyRotation.js:26] {x: 0.0581775, y: 0.0432058, z: -0.0289305, w: 0.996951}

    getting closer :)

  • Coral Orca
    Options

    Ok I got it

    var sourceTransform;

    if (script.sourceObject) {
    sourceTransform = script.sourceObject.getTransform();
    } else {
    print ("[CopyRotation] Source object is not set");
    }

    function onUpdate() {
    if (sourceTransform) {
    print (script.sourceObject.getTransform().getWorldRotation().y);
    }

    }

    var updateEvent = script.createEvent("UpdateEvent");
    updateEvent.bind(onUpdate);