From 7579102b1ac0526ee8ad136b11caa5e588843841 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 20 Jun 2016 15:50:49 -0700 Subject: [PATCH 1/7] updates --- .../DomainContent/Toybox/bow/bow.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/unpublishedScripts/DomainContent/Toybox/bow/bow.js b/unpublishedScripts/DomainContent/Toybox/bow/bow.js index b287966d2c..9a0da44961 100644 --- a/unpublishedScripts/DomainContent/Toybox/bow/bow.js +++ b/unpublishedScripts/DomainContent/Toybox/bow/bow.js @@ -125,6 +125,18 @@ Entities.deleteEntity(this.arrow); }, + startNearGrab:function(entityID, args){ + _this.startEquip(entityID, args); + }, + + continueNearGrab:function(entityID, args){ + _this.continueEquip(entityID, args); + }, + + releaseGrab:function(){ + _this.releaseEquip(); + }, + startEquip: function(entityID, args) { this.hand = args[0]; avatarID = args[1]; @@ -137,6 +149,9 @@ var data = getEntityCustomData('grabbableKey', this.entityID, {}); data.grabbable = false; setEntityCustomData('grabbableKey', this.entityID, data); + Entities.editEntity(_this.entityID, { + collidesWith: "" + }) }, continueEquip: function(entityID, args) { @@ -181,6 +196,9 @@ Entities.deleteEntity(this.arrow); this.aiming = false; this.hasArrowNotched = false; + Entities.editEntity(_this.entityID, { + collidesWith: "static,dynamic,kinematic,otherAvatar,myAvatar" + }) }, createArrow: function() { @@ -526,4 +544,4 @@ }; return new Bow(); -}); +}); \ No newline at end of file From aa742a50ca27549e3641221b9678b18b9ff1eac5 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 20 Jun 2016 16:19:34 -0700 Subject: [PATCH 2/7] release --- unpublishedScripts/DomainContent/Toybox/bow/bow.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unpublishedScripts/DomainContent/Toybox/bow/bow.js b/unpublishedScripts/DomainContent/Toybox/bow/bow.js index 9a0da44961..7dccf06628 100644 --- a/unpublishedScripts/DomainContent/Toybox/bow/bow.js +++ b/unpublishedScripts/DomainContent/Toybox/bow/bow.js @@ -133,8 +133,8 @@ _this.continueEquip(entityID, args); }, - releaseGrab:function(){ - _this.releaseEquip(); + releaseGrab:function(entityID, args){ + _this.releaseEquip(entityID, args); }, startEquip: function(entityID, args) { From f6d19ba32fc53edbe5172c44a07fef21e2b4a0a5 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 20 Jun 2016 16:25:48 -0700 Subject: [PATCH 3/7] add short haptic pulse on release --- unpublishedScripts/DomainContent/Toybox/bow/bow.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unpublishedScripts/DomainContent/Toybox/bow/bow.js b/unpublishedScripts/DomainContent/Toybox/bow/bow.js index 7dccf06628..cba45087a9 100644 --- a/unpublishedScripts/DomainContent/Toybox/bow/bow.js +++ b/unpublishedScripts/DomainContent/Toybox/bow/bow.js @@ -479,10 +479,14 @@ // rotation: arrowProps.rotation }; + //actually shoot the arrow and play its sound Entities.editEntity(this.arrow, arrowProperties); this.playShootArrowSound(); + var whichHand = this.hand==='left' ? 0 :1; + Controller.triggerShortHapticPulse(whichHand, 2); + //clear the strings back to only the single straight one this.deleteStrings(); Entities.editEntity(this.preNotchString, { From d8aeb26a6ceae98c97550ad9d9d54239200f801e Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 20 Jun 2016 16:26:48 -0700 Subject: [PATCH 4/7] haptic --- unpublishedScripts/DomainContent/Toybox/bow/bow.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unpublishedScripts/DomainContent/Toybox/bow/bow.js b/unpublishedScripts/DomainContent/Toybox/bow/bow.js index cba45087a9..2430b68076 100644 --- a/unpublishedScripts/DomainContent/Toybox/bow/bow.js +++ b/unpublishedScripts/DomainContent/Toybox/bow/bow.js @@ -125,15 +125,15 @@ Entities.deleteEntity(this.arrow); }, - startNearGrab:function(entityID, args){ + startNearGrab: function(entityID, args) { _this.startEquip(entityID, args); }, - continueNearGrab:function(entityID, args){ + continueNearGrab: function(entityID, args) { _this.continueEquip(entityID, args); }, - releaseGrab:function(entityID, args){ + releaseGrab: function(entityID, args) { _this.releaseEquip(entityID, args); }, @@ -484,7 +484,7 @@ Entities.editEntity(this.arrow, arrowProperties); this.playShootArrowSound(); - var whichHand = this.hand==='left' ? 0 :1; + var whichHand = this.hand === 'left' ? 0 : 1; Controller.triggerShortHapticPulse(whichHand, 2); //clear the strings back to only the single straight one From fcb6e7869dce8583dca423fc94a0acafd44b757e Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 29 Jun 2016 10:54:24 -0700 Subject: [PATCH 5/7] logging --- .../DomainContent/Toybox/bow/bow.js | 5 ++- .../DomainContent/Toybox/bow/createBow.js | 41 ++++++++++++------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/unpublishedScripts/DomainContent/Toybox/bow/bow.js b/unpublishedScripts/DomainContent/Toybox/bow/bow.js index 2430b68076..02854e4de4 100644 --- a/unpublishedScripts/DomainContent/Toybox/bow/bow.js +++ b/unpublishedScripts/DomainContent/Toybox/bow/bow.js @@ -484,8 +484,9 @@ Entities.editEntity(this.arrow, arrowProperties); this.playShootArrowSound(); - var whichHand = this.hand === 'left' ? 0 : 1; - Controller.triggerShortHapticPulse(whichHand, 2); + var backHand = this.hand === 'left' ? 1 : 0; + var haptic = Controller.triggerShortHapticPulse(1, backHand); + print('JBP TRIGGERED HAPTIC ' + haptic +" hand: "+ backHand) //clear the strings back to only the single straight one this.deleteStrings(); diff --git a/unpublishedScripts/DomainContent/Toybox/bow/createBow.js b/unpublishedScripts/DomainContent/Toybox/bow/createBow.js index 5deec3f6bc..4daeba320a 100644 --- a/unpublishedScripts/DomainContent/Toybox/bow/createBow.js +++ b/unpublishedScripts/DomainContent/Toybox/bow/createBow.js @@ -62,24 +62,35 @@ function makeBow() { shapeType: 'compound', compoundShapeURL: COLLISION_HULL_URL, script: SCRIPT_URL, + collidesWith: 'dynamic,kinetmatic,static', userData: JSON.stringify({ grabbableKey: { invertSolidWhileHeld: true }, - wearable:{joints:{RightHand:[{x:0.03960523009300232, - y:0.01979270577430725, - z:0.03294898942112923}, - {x:-0.7257906794548035, - y:-0.4611682891845703, - z:0.4436084032058716, - w:-0.25251442193984985}], - LeftHand:[{x:0.0055799782276153564, - y:0.04354757443070412, - z:0.05119767785072327}, - {x:-0.14914104342460632, - y:0.6448180079460144, - z:-0.2888556718826294, - w:-0.6917579770088196}]}} + wearable: { + joints: { + RightHand: [{ + x: 0.03960523009300232, + y: 0.01979270577430725, + z: 0.03294898942112923 + }, { + x: -0.7257906794548035, + y: -0.4611682891845703, + z: 0.4436084032058716, + w: -0.25251442193984985 + }], + LeftHand: [{ + x: 0.0055799782276153564, + y: 0.04354757443070412, + z: 0.05119767785072327 + }, { + x: -0.14914104342460632, + y: 0.6448180079460144, + z: -0.2888556718826294, + w: -0.6917579770088196 + }] + } + } }) }; @@ -148,4 +159,4 @@ function cleanup() { Entities.deleteEntity(preNotchString); } -Script.scriptEnding.connect(cleanup); +Script.scriptEnding.connect(cleanup); \ No newline at end of file From 0e3b54c1303b26b8663b27eb32574b25fb25e2c9 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 29 Jun 2016 11:07:48 -0700 Subject: [PATCH 6/7] remove logging --- unpublishedScripts/DomainContent/Toybox/bow/bow.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/unpublishedScripts/DomainContent/Toybox/bow/bow.js b/unpublishedScripts/DomainContent/Toybox/bow/bow.js index 02854e4de4..89a3d166d6 100644 --- a/unpublishedScripts/DomainContent/Toybox/bow/bow.js +++ b/unpublishedScripts/DomainContent/Toybox/bow/bow.js @@ -143,7 +143,6 @@ //disable the opposite hand in handControllerGrab.js by message var handToDisable = this.hand === 'right' ? 'left' : 'right'; - print("disabling hand: " + handToDisable); Messages.sendMessage('Hifi-Hand-Disabler', handToDisable); var data = getEntityCustomData('grabbableKey', this.entityID, {}); @@ -202,7 +201,7 @@ }, createArrow: function() { - print('create arrow') + // print('create arrow') this.playArrowNotchSound(); var arrow = Entities.addEntity({ @@ -486,7 +485,6 @@ var backHand = this.hand === 'left' ? 1 : 0; var haptic = Controller.triggerShortHapticPulse(1, backHand); - print('JBP TRIGGERED HAPTIC ' + haptic +" hand: "+ backHand) //clear the strings back to only the single straight one this.deleteStrings(); From 6d3129899beadd857582a00ee395be3733ca9142 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 29 Jun 2016 11:47:41 -0700 Subject: [PATCH 7/7] remove prints, fix typo, formatting --- .../DomainContent/Toybox/bow/bow.js | 43 ++++++++----------- .../DomainContent/Toybox/bow/createBow.js | 2 +- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/unpublishedScripts/DomainContent/Toybox/bow/bow.js b/unpublishedScripts/DomainContent/Toybox/bow/bow.js index 89a3d166d6..0c16bcbc7b 100644 --- a/unpublishedScripts/DomainContent/Toybox/bow/bow.js +++ b/unpublishedScripts/DomainContent/Toybox/bow/bow.js @@ -183,7 +183,6 @@ }, releaseEquip: function(entityID, args) { - // print('RELEASE GRAB EVENT') Messages.sendMessage('Hifi-Hand-Disabler', "none") this.stringDrawn = false; @@ -201,7 +200,6 @@ }, createArrow: function() { - // print('create arrow') this.playArrowNotchSound(); var arrow = Entities.addEntity({ @@ -226,25 +224,24 @@ var makeArrowStick = function(entityA, entityB, collision) { Entities.editEntity(entityA, { - angularVelocity: { - x: 0, - y: 0, - z: 0 - }, - velocity: { - x: 0, - y: 0, - z: 0 - }, - gravity: { - x: 0, - y: 0, - z: 0 - }, - position: collision.contactPoint, - dynamic: false - }) - // print('ARROW COLLIDED WITH::' + entityB); + angularVelocity: { + x: 0, + y: 0, + z: 0 + }, + velocity: { + x: 0, + y: 0, + z: 0 + }, + gravity: { + x: 0, + y: 0, + z: 0 + }, + position: collision.contactPoint, + dynamic: false + }) Script.removeEventHandler(arrow, "collisionWithEntity", makeArrowStick) } @@ -300,7 +297,6 @@ }, updateStringPositions: function() { - // print('update string positions!!!') var upVector = Quat.getUp(this.bowProperties.rotation); var upOffset = Vec3.multiply(upVector, TOP_NOTCH_OFFSET); var downVector = Vec3.multiply(-1, Quat.getUp(this.bowProperties.rotation)); @@ -371,7 +367,6 @@ if (this.triggerValue < DRAW_STRING_THRESHOLD && this.stringDrawn === true) { // firing the arrow - // print('HIT RELEASE LOOP IN CHECK'); this.drawStrings(); this.hasArrowNotched = false; @@ -381,7 +376,6 @@ } else if (this.triggerValue > DRAW_STRING_THRESHOLD && this.stringDrawn === true) { - // print('HIT CONTINUE LOOP IN CHECK') //continuing to aim the arrow this.aiming = true; @@ -389,7 +383,6 @@ this.updateArrowPositionInNotch(); } else if (this.triggerValue > DRAW_STRING_THRESHOLD && this.stringDrawn === false) { - // print('HIT START LOOP IN CHECK'); this.arrow = this.createArrow(); this.playStringPullSound(); diff --git a/unpublishedScripts/DomainContent/Toybox/bow/createBow.js b/unpublishedScripts/DomainContent/Toybox/bow/createBow.js index 4daeba320a..f1ed9eb263 100644 --- a/unpublishedScripts/DomainContent/Toybox/bow/createBow.js +++ b/unpublishedScripts/DomainContent/Toybox/bow/createBow.js @@ -62,7 +62,7 @@ function makeBow() { shapeType: 'compound', compoundShapeURL: COLLISION_HULL_URL, script: SCRIPT_URL, - collidesWith: 'dynamic,kinetmatic,static', + collidesWith: 'dynamic,kinematic,static', userData: JSON.stringify({ grabbableKey: { invertSolidWhileHeld: true