mirror of
https://github.com/overte-org/overte.git
synced 2025-08-18 11:34:57 +02:00
werk
This commit is contained in:
parent
7166c6ddd2
commit
48a295f4bc
5 changed files with 48 additions and 30 deletions
|
@ -286,10 +286,7 @@ function MyController(hand, triggerAction) {
|
|||
|
||||
this.search = function() {
|
||||
//if this hand is the one that's disabled, we don't want to search for anything at all
|
||||
if (this.hand === disabledHand) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
return;
|
||||
|
@ -303,7 +300,14 @@ function MyController(hand, triggerAction) {
|
|||
length: PICK_MAX_DISTANCE
|
||||
};
|
||||
|
||||
this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
||||
if (this.hand === disabledHand) {
|
||||
|
||||
}
|
||||
else{
|
||||
this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// don't pick 60x per second.
|
||||
var pickRays = [];
|
||||
|
|
|
@ -102,8 +102,14 @@
|
|||
});
|
||||
|
||||
setEntityCustomData('grabbableKey', this.entityID, {
|
||||
grabbable: false
|
||||
grabbable: false,
|
||||
invertSolidWhileHeld:true
|
||||
});
|
||||
|
||||
Entities.editEntity(this.entityID,{
|
||||
collisionsWillMove:false,
|
||||
ignoreForCollisions:true
|
||||
})
|
||||
|
||||
setEntityCustomData('hifiBowKey', bowID, {
|
||||
hasArrowNotched: true,
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
z: 1000
|
||||
};
|
||||
|
||||
var ARROW_OFFSET = 0.32;
|
||||
var ARROW_OFFSET = -0.36;
|
||||
|
||||
var ARROW_GRAVITY = {
|
||||
x: 0,
|
||||
|
@ -98,9 +98,9 @@
|
|||
fire: null,
|
||||
stringData: {
|
||||
currentColor: {
|
||||
red: 0,
|
||||
red: 255,
|
||||
green: 255,
|
||||
blue: 0
|
||||
blue: 255
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -138,7 +138,6 @@
|
|||
},
|
||||
|
||||
continueNearGrab: function() {
|
||||
print('GRABBING BOW!!')
|
||||
this.bowProperties = Entities.getEntityProperties(this.entityID, ["position", "rotation", "userData"]);
|
||||
this.updateNotchDetectorPosition();
|
||||
|
||||
|
@ -146,13 +145,10 @@
|
|||
var userData = JSON.parse(this.bowProperties.userData);
|
||||
if (userData.hasOwnProperty('hifiBowKey')) {
|
||||
if (this.hasArrowNotched === false) {
|
||||
//notch the arrow
|
||||
this.hasArrowNotched = userData.hifiBowKey.hasArrowNotched;
|
||||
|
||||
this.arrow = userData.hifiBowKey.arrowID;
|
||||
Entities.editEntity(this.arrow, {
|
||||
collisionsWillMove: false,
|
||||
ignoreForCollisions: true
|
||||
});
|
||||
|
||||
setEntityCustomData('grabbableKey', this.entityID, {
|
||||
turnOffOtherHand: true,
|
||||
|
@ -365,16 +361,16 @@
|
|||
if (this.triggerValue < DRAW_STRING_THRESHOLD && this.stringDrawn === true) {
|
||||
|
||||
// firing the arrow
|
||||
this.stringDrawn = false;
|
||||
this.deleteStrings();
|
||||
this.hasArrow = false;
|
||||
this.releaseArrow();
|
||||
// this.stringDrawn = false;
|
||||
// this.deleteStrings();
|
||||
// this.hasArrow = false;
|
||||
// this.releaseArrow();
|
||||
|
||||
} else if (this.triggerValue >= DRAW_STRING_THRESHOLD && this.stringDrawn === true) {
|
||||
//continuing to aim the arrow
|
||||
this.stringData.handPosition = this.getStringHandPosition();
|
||||
this.stringData.handRotation = this.getStringHandRotation();
|
||||
// this.initialHand === 'right' ? this.stringData.grabHandPosition = Controller.getSpatialControlPosition(RIGHT_TIP) : this.stringData.grabHandPosition = Controller.getSpatialControlPosition(LEFT_TIP);
|
||||
this.initialHand === 'right' ? this.stringData.grabHandPosition = Controller.getSpatialControlPosition(RIGHT_TIP) : this.stringData.grabHandPosition = Controller.getSpatialControlPosition(LEFT_TIP);
|
||||
this.stringData.grabHandRotation = this.getGrabHandRotation();
|
||||
this.drawStrings();
|
||||
this.updateArrowPositionInNotch();
|
||||
|
@ -385,7 +381,7 @@
|
|||
this.createStrings();
|
||||
this.stringData.handPosition = this.getStringHandPosition();
|
||||
this.stringData.handRotation = this.getStringHandRotation();
|
||||
// this.initialHand === 'right' ? this.stringData.grabHandPosition = Controller.getSpatialControlPosition(RIGHT_TIP) : this.stringData.grabHandPosition = Controller.getSpatialControlPosition(LEFT_TIP);
|
||||
this.initialHand === 'right' ? this.stringData.grabHandPosition = Controller.getSpatialControlPosition(RIGHT_TIP) : this.stringData.grabHandPosition = Controller.getSpatialControlPosition(LEFT_TIP);
|
||||
this.stringData.grabHandRotation = this.getGrabHandRotation();
|
||||
|
||||
this.drawStrings();
|
||||
|
@ -425,23 +421,29 @@
|
|||
},
|
||||
|
||||
|
||||
|
||||
updateArrowPositionInNotch: function() {
|
||||
|
||||
|
||||
var arrowOffset = Vec3.multiply(Quat.getFront(this.bowProperties.rotation), ARROW_OFFSET);
|
||||
var arrowPosition = Vec3.sum(this.notchDetectorPosition, arrowOffset)
|
||||
|
||||
//move it backwards
|
||||
var handToNotch = Vec3.subtract(this.stringData.handPosition, this.notchDetectorPosition);
|
||||
var pullBackDistance = Vec3.length(handToNotch);
|
||||
|
||||
if(pullBackDistance>=0.6){
|
||||
pullBackDistance= 0.6;
|
||||
}
|
||||
|
||||
var pullBackOffset = Vec3.multiply(handToNotch,pullBackDistance);
|
||||
var arrowPosition = Vec3.sum(this.notchDetectorPosition,pullBackOffset);
|
||||
|
||||
var pushForwardOffset = Vec3.multiply(handToNotch, ARROW_OFFSET);
|
||||
var finalArrowPosition = Vec3.sum(arrowPosition, pushForwardOffset);
|
||||
|
||||
var arrowRotation = this.orientationOf(handToNotch);
|
||||
|
||||
Entities.editEntity(this.arrow, {
|
||||
position: this.notchDetectorPosition,
|
||||
position: finalArrowPosition,
|
||||
rotation: arrowRotation
|
||||
})
|
||||
|
||||
|
||||
if (this.arrowIsBurning === true) {
|
||||
Entities.editEntity(this.fire, {
|
||||
position: arrowTipPosition
|
||||
|
@ -534,6 +536,7 @@
|
|||
detectorPosition = Vec3.sum(detectorPosition, notchVectorUp);
|
||||
|
||||
this.notchDetectorPosition = detectorPosition;
|
||||
|
||||
Entities.editEntity(this.notchDetector, {
|
||||
position: this.notchDetectorPosition
|
||||
});
|
||||
|
|
|
@ -47,10 +47,15 @@ function createArrow() {
|
|||
compoundShapeURL: ARROW_COLLISION_HULL_URL,
|
||||
dimensions: ARROW_DIMENSIONS,
|
||||
position: center,
|
||||
script:ARROW_SCRIPT_URL,
|
||||
script: ARROW_SCRIPT_URL,
|
||||
collisionsWillMove: true,
|
||||
ignoreForCollisions: false,
|
||||
gravity: ARROW_GRAVITY
|
||||
gravity: ARROW_GRAVITY,
|
||||
userData: JSON.stringify({
|
||||
grabbableKey: {
|
||||
invertSolidWhileHeld: true
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ var bow = Entities.addEntity({
|
|||
script: SCRIPT_URL,
|
||||
userData: JSON.stringify({
|
||||
grabbableKey: {
|
||||
turnOffOppositeBeam: false,
|
||||
turnOffOppositeBeam: true,
|
||||
invertSolidWhileHeld: true
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue