51 lines
No EOL
1.8 KiB
JavaScript
51 lines
No EOL
1.8 KiB
JavaScript
|
|
(function() {
|
|
var count = 0;
|
|
var chair = Entities.findEntitiesByName("buster chair", MyAvatar.position, 10000)[0];
|
|
|
|
function blowUpAnimation() {
|
|
Script.setTimeout(function() {
|
|
MyAvatar.motorReferenceFrame = 'world';
|
|
MyAvatar.motorVelocity = { x: 5, y: 10, z: 5 };
|
|
MyAvatar.motorTimescale = 0.10; MyAvatar.motorMode= "dynamic";
|
|
Script.setTimeout(function() {
|
|
MyAvatar.motorReferenceFrame = 'camera';
|
|
MyAvatar.motorVelocity = { x: 0, y: 0, z: 0 };
|
|
MyAvatar.motorTimescale = 1000000; MyAvatar.motorMode= "simple";
|
|
Entities.editEntity(chair, {visible: false});
|
|
}, 200);
|
|
|
|
MyAvatar.overrideAnimation('https://hifi-content.s3.amazonaws.com/brosche/dev/Particle-Sequencer/FlyingBackDeath2.fbx',30, false, 0, 54);
|
|
}, 3000);
|
|
count = 0;
|
|
}
|
|
|
|
function messageHandler(channel, message) {
|
|
if (channel === "BUSTERBOMB") {
|
|
try {
|
|
message = JSON.parse(message);
|
|
} catch (e) {
|
|
console.log("unable to parse message", e);
|
|
return;
|
|
}
|
|
if (message && message.message === "get ready" && count < 1) {
|
|
count = 1;
|
|
blowUpAnimation();
|
|
} else if (message && message.message === "reset") {
|
|
MyAvatar.restoreAnimation();
|
|
Entities.editEntity(chair, {visible: true});
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function end() {
|
|
Messages.unsubscribe("BUSTERBOMB");
|
|
Messages.messageReceived.disconnect(messageHandler);
|
|
}
|
|
|
|
Messages.subscribe("BUSTERBOMB");
|
|
Messages.messageReceived.connect(messageHandler);
|
|
Script.scriptEnding.connect(end);
|
|
|
|
}()); |