draw strings sooner, arrow force squared, disable grab on arrow

This commit is contained in:
James B. Pollack 2015-11-20 10:26:41 -08:00
parent e41cc0979c
commit 8a65c7a48f

View file

@ -133,6 +133,7 @@
notchDetector: null, notchDetector: null,
arrow: null, arrow: null,
arrowIsBurning: false, arrowIsBurning: false,
prePickupString: null,
stringData: { stringData: {
currentColor: { currentColor: {
red: 255, red: 255,
@ -149,7 +150,7 @@
this.arrowHitSound = SoundCache.getSound(ARROW_HIT_SOUND_URL); this.arrowHitSound = SoundCache.getSound(ARROW_HIT_SOUND_URL);
this.arrowNotchSound = SoundCache.getSound(NOTCH_ARROW_SOUND_URL); this.arrowNotchSound = SoundCache.getSound(NOTCH_ARROW_SOUND_URL);
this.arrowWhizzSound = SoundCache.getSound(ARROW_WHIZZ_SOUND_URL); this.arrowWhizzSound = SoundCache.getSound(ARROW_WHIZZ_SOUND_URL);
//Script.update.connect(this.updateArrowTrackers); Script.update.connect(this.drawStringsBeforePickup);
}, },
@ -170,6 +171,8 @@
Entities.deleteEntity(this.notchDetector); Entities.deleteEntity(this.notchDetector);
Entities.deleteEntity(this.preNotchString); Entities.deleteEntity(this.preNotchString);
Entities.deleteEntity(this.arrow); Entities.deleteEntity(this.arrow);
Entities.deleteEntity(this.preNotchString);
Script.update.disconnect(this.drawStringsBeforePickup);
}, },
@ -234,8 +237,8 @@
if (this.preNotchString !== null && this.aiming === false) { if (this.preNotchString !== null && this.aiming === false) {
// print('DRAW PRE NOTCH STRING') // print('DRAW PRE NOTCH STRING')
this.drawPreNotchStrings(); // this.drawPreNotchStrings();
this.updateArrowAttachedToBow(); // this.updateArrowAttachedToBow();
} }
// create the notch detector that arrows will look for // create the notch detector that arrows will look for
@ -277,12 +280,12 @@
spatialKey: BOW_SPATIAL_KEY spatialKey: BOW_SPATIAL_KEY
}); });
Entities.deleteEntity(this.notchDetector); Entities.deleteEntity(this.notchDetector);
Entities.deleteEntity(this.preNotchString); // Entities.deleteEntity(this.preNotchString);
Entities.deleteEntity(this.arrow); Entities.deleteEntity(this.arrow);
this.aiming = false; this.aiming = false;
this.notchDetector = null; this.notchDetector = null;
this.hasArrowNotched = false; this.hasArrowNotched = false;
this.preNotchString = null; // this.preNotchString = null;
} }
}, },
@ -303,7 +306,12 @@
ignoreForCollisions: true, ignoreForCollisions: true,
collisionSoundURL: 'http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/sounds/Arrow_impact1.L.wav', collisionSoundURL: 'http://hifi-content.s3.amazonaws.com/james/bow_and_arrow/sounds/Arrow_impact1.L.wav',
gravity: ARROW_GRAVITY, gravity: ARROW_GRAVITY,
linearDamping: 0.01 linearDamping: 0.01,
userData: JSON.stringify({
grabbableKey: {
grabbable: false
}
})
}); });
return arrow return arrow
@ -412,6 +420,17 @@
return [topVector, bottomVector]; return [topVector, bottomVector];
}, },
drawStringsBeforePickup: function() {
this.bowProperties = Entities.getEntityProperties(this.entityID, ["position", "rotation", "userData"]);
if (this.prePickupString === null) {
this.createPreNotchString();
} else {
this.drawPreNotchStrings();
}
},
createPreNotchString: function() { createPreNotchString: function() {
var stringProperties = { var stringProperties = {
type: 'Line', type: 'Line',
@ -585,7 +604,7 @@
// handToNotch = Vec3.normalize(handToNotch) // handToNotch = Vec3.normalize(handToNotch)
var forwardVec = handToNotch; var forwardVec = handToNotch;
// var forwardVec = Vec3.multiply(handToNotch, arrowForce); // var forwardVec = Vec3.multiply(handToNotch, arrowForce);
var forwardVec = Vec3.multiply(handToNotch, 2); var forwardVec = Vec3.multiply(handToNotch,handToNotch);
var arrowProperties = { var arrowProperties = {
// rotation: arrowRotation, // rotation: arrowRotation,
velocity: forwardVec, velocity: forwardVec,
@ -609,7 +628,7 @@
this.stringDrawn = false; this.stringDrawn = false;
this.deleteStrings(); this.deleteStrings();
//set an itnerval to heck how far the arrow is from the bow before adding gravity, etc. if we add this too soon, the arrow collides with the bow. hence, this function //set an itnerval to check how far the arrow is from the bow before adding gravity, etc. if we add this too soon, the arrow collides with the bow. hence, this function
var physicalArrowInterval = Script.setInterval(function() { var physicalArrowInterval = Script.setInterval(function() {
// print('in physical interval') // print('in physical interval')