direct haptics to right hand

This commit is contained in:
Kevin Ngo
2018-10-20 18:50:00 -07:00
parent 8a43359842
commit 6797660c66
2 changed files with 6 additions and 3 deletions

View File

@@ -454,12 +454,14 @@ AFRAME.registerComponent('beat', {
if (!saberBoundingBox) { break; }
const hand = saberEls[i].getAttribute('saber-controls').hand;
if (hitBoundingBox && saberBoundingBox.intersectsBox(hitBoundingBox)) {
if (saberEls[i].components['saber-controls'].swinging &&
this.data.color === saberColors[saberEls[i].getAttribute('saber-controls').hand]) {
this.el.emit('beathit', null, true);
this.el.emit(`beathit${hand}`, null, true);
} else {
this.wrongHit(saberEls[i].getAttribute('saber-controls').hand);
this.wrongHit(hand);
}
this.el.parentNode.components['beat-hit-sound'].playSound(
this.el, this.data.cutDirection);
@@ -478,8 +480,9 @@ AFRAME.registerComponent('beat', {
if (this.data.type === 'dot' && saberEls[i].components['saber-controls'].swinging &&
this.data.color === saberColors[saberEls[i].getAttribute('saber-controls').hand]) {
this.el.emit('beathit', null, true);
this.el.emit(`beathit${hand}`, null, true);
} else {
this.wrongHit(saberEls[i].getAttribute('saber-controls').hand);
this.wrongHit(hand);
}
break;
}

View File

@@ -110,7 +110,7 @@
bind__saber-controls="bladeEnabled: isPlaying; isPaused: isPaused"
bind__trail="enabled: isPlaying"
haptics="events: mouseenter; dur: 35; force: 0.075"
haptics__beat="eventsFrom: #beatContainer; events: beathit; dur: 80; force: 0.2"
haptics__beat="eventsFrom: #beatContainer; events: beathit{{ hand }}; dur: 80; force: 0.2"
haptics__draw="events: drawblade; dur: 750; force: 0.025"
saber-controls="hand: {{ hand }}"
thumb-controls