Skip to content

Instantly share code, notes, and snippets.

@hyperlogic
Created October 31, 2019 23:21
Show Gist options
  • Save hyperlogic/ae739c923e81f52e5c81153a86c18694 to your computer and use it in GitHub Desktop.
Save hyperlogic/ae739c923e81f52e5c81153a86c18694 to your computer and use it in GitHub Desktop.
var normalizedMousePos = {x: 0, y: 0};
function animHandler(props) {
props.lookAroundAlpha = {x: normalizedMousePos.x, y: -normalizedMousePos.y, z: 0};
return props;
}
Controller.mouseMoveEvent.connect(function (e) {
normalizedMousePos.x = ((2 * e.x) / Window.innerWidth) - 1;
normalizedMousePos.y = ((2 * e.y) / Window.innerHeight) - 1;
});
animHandlerId = MyAvatar.addAnimationStateHandler(animHandler, ["lookAroundAlpha"]);
Script.scriptEnding.connect(function () {
MyAvatar.removeAnimationStateHandler(animHandlerId);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment