mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 11:48:52 +02:00
Vibrate only the controller that hits the key and decrease timeout so that the xylophone can be played faster
This commit is contained in:
parent
119b10886f
commit
1f6b92a519
2 changed files with 15 additions and 9 deletions
|
@ -9,12 +9,12 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var TIMEOUT = 150;
|
var TIMEOUT = 50; // at 30 ms, the key's color sometimes fails to switch when hit
|
||||||
var TEXTURE_GRAY = Script.resolvePath("xylotex_bar_gray.png");
|
var TEXTURE_GRAY = Script.resolvePath("xylotex_bar_gray.png");
|
||||||
var TEXTURE_BLACK = Script.resolvePath("xylotex_bar_black.png");
|
var TEXTURE_BLACK = Script.resolvePath("xylotex_bar_black.png");
|
||||||
var IS_DEBUG = false;
|
var IS_DEBUG = false;
|
||||||
var _this;
|
var _this;
|
||||||
|
|
||||||
function XylophoneKey() {
|
function XylophoneKey() {
|
||||||
_this = this;
|
_this = this;
|
||||||
}
|
}
|
||||||
|
@ -34,24 +34,28 @@
|
||||||
|
|
||||||
collisionWithEntity: function(thisEntity, otherEntity, collision) {
|
collisionWithEntity: function(thisEntity, otherEntity, collision) {
|
||||||
if (collision.type === 0) {
|
if (collision.type === 0) {
|
||||||
_this.hit();
|
_this.hit(otherEntity);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
clickDownOnEntity: function() {
|
clickDownOnEntity: function(otherEntity) {
|
||||||
_this.hit();
|
_this.hit(otherEntity);
|
||||||
},
|
},
|
||||||
|
|
||||||
hit: function() {
|
hit: function(otherEntity) {
|
||||||
if (!_this.isWaiting) {
|
if (!_this.isWaiting) {
|
||||||
_this.isWaiting = true;
|
_this.isWaiting = true;
|
||||||
_this.homePosition = Entities.getEntityProperties(_this.entityID, ["position"]).position;
|
_this.homePosition = Entities.getEntityProperties(_this.entityID, ["position"]).position;
|
||||||
_this.injector = Audio.playSound(_this.sound, {position: _this.homePosition, volume: 1});
|
_this.injector = Audio.playSound(_this.sound, {position: _this.homePosition, volume: 1});
|
||||||
_this.editEntityTextures(_this.entityID, "file5", TEXTURE_GRAY);
|
_this.editEntityTextures(_this.entityID, "file5", TEXTURE_GRAY);
|
||||||
|
|
||||||
var HAPTIC_STRENGTH = 1;
|
var HAPTIC_STRENGTH = 1;
|
||||||
var HAPTIC_DURATION = 20;
|
var HAPTIC_DURATION = 20;
|
||||||
var HAPTIC_HAND = 2; // Both hands
|
var userData = JSON.parse(Entities.getEntityProperties(otherEntity, 'userData').userData);
|
||||||
Controller.triggerHapticPulse(HAPTIC_STRENGTH, HAPTIC_DURATION, HAPTIC_HAND);
|
if (userData.hasOwnProperty('hand')){
|
||||||
|
Controller.triggerHapticPulse(HAPTIC_STRENGTH, HAPTIC_DURATION, userData.hand);
|
||||||
|
}
|
||||||
|
|
||||||
_this.timeout();
|
_this.timeout();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
var SOUND_FILES = ["C4.wav", "D4.wav", "E4.wav", "F4.wav", "G4.wav", "A4.wav", "B4.wav", "C5.wav"];
|
var SOUND_FILES = ["C4.wav", "D4.wav", "E4.wav", "F4.wav", "G4.wav", "A4.wav", "B4.wav", "C5.wav"];
|
||||||
var KEY_MODEL_URL = Script.resolvePath("xyloKey_2_a_e.fbx");
|
var KEY_MODEL_URL = Script.resolvePath("xyloKey_2_a_e.fbx");
|
||||||
var KEY_SCRIPT_URL = Script.resolvePath("xylophoneKey.js");
|
var KEY_SCRIPT_URL = Script.resolvePath("xylophoneKey.js");
|
||||||
|
var MALLET_SCRIPT_URL = Script.resolvePath("xylophoneMallet.js");
|
||||||
var TEXTURE_BLACK = Script.resolvePath("xylotex_bar_black.png");
|
var TEXTURE_BLACK = Script.resolvePath("xylotex_bar_black.png");
|
||||||
var MALLET_MODEL_URL = Script.resolvePath("Mallet3-2pc.fbx");
|
var MALLET_MODEL_URL = Script.resolvePath("Mallet3-2pc.fbx");
|
||||||
var MALLET_MODEL_COLLIDER_URL = Script.resolvePath("Mallet3-2bpc_phys.obj");
|
var MALLET_MODEL_COLLIDER_URL = Script.resolvePath("Mallet3-2bpc_phys.obj");
|
||||||
|
@ -91,6 +92,7 @@ function rezMallets() {
|
||||||
damping: 1,
|
damping: 1,
|
||||||
angularDamping: 1,
|
angularDamping: 1,
|
||||||
shapeType: "compound",
|
shapeType: "compound",
|
||||||
|
script: MALLET_SCRIPT_URL,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
invertSolidWhileHeld: true
|
invertSolidWhileHeld: true
|
||||||
|
|
Loading…
Reference in a new issue