Skip to content

Instantly share code, notes, and snippets.

@humbletim
Created July 2, 2016 20:44
Show Gist options
  • Save humbletim/02143181479fe0faf120dbffc6cbaee7 to your computer and use it in GitHub Desktop.
Save humbletim/02143181479fe0faf120dbffc6cbaee7 to your computer and use it in GitHub Desktop.
Avatar Eargonomics
observeModeChanges(); // defined below
// --------------------------------------------------------------
// hear from your Avatar's perspective
MyAvatar.audioListenerMode = MyAvatar.audioListenerModeHead;
// --------------------------------------------------------------
// hear from the Camera's perspective
MyAvatar.audioListenerMode = MyAvatar.audioListenerModeCamera;
// --------------------------------------------------------------
// hear from a Custom position and orientation
// for example, let an Entity be your ears:
var uuid = Entities.findClosestEntity(MyAvatar.position, 10),
props = Entities.getEntityProperties(uuid, ['position','rotation']);
MyAvatar.audioListenerMode = MyAvatar.audioListenerModeCustom;
MyAvatar.customListenPosition = props.position;
MyAvatar.customListenOrientation = props.rotation;
// --------------------------------------------------------------
// restore the default mode
MyAvatar.audioListenerMode = MyAvatar.audioListenerModeHead;
// --------------------------------------------------------------
// observing mode changes...
function observeModeChanges() {
function modeChanged() {
print('Audio Listen Mode Changed: ', ['Head','Camera','Custom'][MyAvatar.audioListenerMode]);
}
MyAvatar.audioListenerModeChanged.connect(modeChanged);
Script.scriptEnding.connect(function(){
MyAvatar.audioListenerModeChanged.disconnect(modeChanged);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment