mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:18:05 +02:00
commit
b7619f2d78
2 changed files with 67 additions and 42 deletions
|
@ -125,18 +125,32 @@
|
||||||
Entities.deleteEntity(this.arrow);
|
Entities.deleteEntity(this.arrow);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
startNearGrab: function(entityID, args) {
|
||||||
|
_this.startEquip(entityID, args);
|
||||||
|
},
|
||||||
|
|
||||||
|
continueNearGrab: function(entityID, args) {
|
||||||
|
_this.continueEquip(entityID, args);
|
||||||
|
},
|
||||||
|
|
||||||
|
releaseGrab: function(entityID, args) {
|
||||||
|
_this.releaseEquip(entityID, args);
|
||||||
|
},
|
||||||
|
|
||||||
startEquip: function(entityID, args) {
|
startEquip: function(entityID, args) {
|
||||||
this.hand = args[0];
|
this.hand = args[0];
|
||||||
avatarID = args[1];
|
avatarID = args[1];
|
||||||
|
|
||||||
//disable the opposite hand in handControllerGrab.js by message
|
//disable the opposite hand in handControllerGrab.js by message
|
||||||
var handToDisable = this.hand === 'right' ? 'left' : 'right';
|
var handToDisable = this.hand === 'right' ? 'left' : 'right';
|
||||||
print("disabling hand: " + handToDisable);
|
|
||||||
Messages.sendMessage('Hifi-Hand-Disabler', handToDisable);
|
Messages.sendMessage('Hifi-Hand-Disabler', handToDisable);
|
||||||
|
|
||||||
var data = getEntityCustomData('grabbableKey', this.entityID, {});
|
var data = getEntityCustomData('grabbableKey', this.entityID, {});
|
||||||
data.grabbable = false;
|
data.grabbable = false;
|
||||||
setEntityCustomData('grabbableKey', this.entityID, data);
|
setEntityCustomData('grabbableKey', this.entityID, data);
|
||||||
|
Entities.editEntity(_this.entityID, {
|
||||||
|
collidesWith: ""
|
||||||
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
continueEquip: function(entityID, args) {
|
continueEquip: function(entityID, args) {
|
||||||
|
@ -169,7 +183,6 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
releaseEquip: function(entityID, args) {
|
releaseEquip: function(entityID, args) {
|
||||||
// print('RELEASE GRAB EVENT')
|
|
||||||
Messages.sendMessage('Hifi-Hand-Disabler', "none")
|
Messages.sendMessage('Hifi-Hand-Disabler', "none")
|
||||||
|
|
||||||
this.stringDrawn = false;
|
this.stringDrawn = false;
|
||||||
|
@ -181,10 +194,12 @@
|
||||||
Entities.deleteEntity(this.arrow);
|
Entities.deleteEntity(this.arrow);
|
||||||
this.aiming = false;
|
this.aiming = false;
|
||||||
this.hasArrowNotched = false;
|
this.hasArrowNotched = false;
|
||||||
|
Entities.editEntity(_this.entityID, {
|
||||||
|
collidesWith: "static,dynamic,kinematic,otherAvatar,myAvatar"
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
createArrow: function() {
|
createArrow: function() {
|
||||||
print('create arrow')
|
|
||||||
this.playArrowNotchSound();
|
this.playArrowNotchSound();
|
||||||
|
|
||||||
var arrow = Entities.addEntity({
|
var arrow = Entities.addEntity({
|
||||||
|
@ -209,25 +224,24 @@
|
||||||
|
|
||||||
var makeArrowStick = function(entityA, entityB, collision) {
|
var makeArrowStick = function(entityA, entityB, collision) {
|
||||||
Entities.editEntity(entityA, {
|
Entities.editEntity(entityA, {
|
||||||
angularVelocity: {
|
angularVelocity: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
z: 0
|
z: 0
|
||||||
},
|
},
|
||||||
velocity: {
|
velocity: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
z: 0
|
z: 0
|
||||||
},
|
},
|
||||||
gravity: {
|
gravity: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
z: 0
|
z: 0
|
||||||
},
|
},
|
||||||
position: collision.contactPoint,
|
position: collision.contactPoint,
|
||||||
dynamic: false
|
dynamic: false
|
||||||
})
|
})
|
||||||
// print('ARROW COLLIDED WITH::' + entityB);
|
|
||||||
Script.removeEventHandler(arrow, "collisionWithEntity", makeArrowStick)
|
Script.removeEventHandler(arrow, "collisionWithEntity", makeArrowStick)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +297,6 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
updateStringPositions: function() {
|
updateStringPositions: function() {
|
||||||
// print('update string positions!!!')
|
|
||||||
var upVector = Quat.getUp(this.bowProperties.rotation);
|
var upVector = Quat.getUp(this.bowProperties.rotation);
|
||||||
var upOffset = Vec3.multiply(upVector, TOP_NOTCH_OFFSET);
|
var upOffset = Vec3.multiply(upVector, TOP_NOTCH_OFFSET);
|
||||||
var downVector = Vec3.multiply(-1, Quat.getUp(this.bowProperties.rotation));
|
var downVector = Vec3.multiply(-1, Quat.getUp(this.bowProperties.rotation));
|
||||||
|
@ -354,7 +367,6 @@
|
||||||
|
|
||||||
if (this.triggerValue < DRAW_STRING_THRESHOLD && this.stringDrawn === true) {
|
if (this.triggerValue < DRAW_STRING_THRESHOLD && this.stringDrawn === true) {
|
||||||
// firing the arrow
|
// firing the arrow
|
||||||
// print('HIT RELEASE LOOP IN CHECK');
|
|
||||||
|
|
||||||
this.drawStrings();
|
this.drawStrings();
|
||||||
this.hasArrowNotched = false;
|
this.hasArrowNotched = false;
|
||||||
|
@ -364,7 +376,6 @@
|
||||||
|
|
||||||
|
|
||||||
} else if (this.triggerValue > DRAW_STRING_THRESHOLD && this.stringDrawn === true) {
|
} else if (this.triggerValue > DRAW_STRING_THRESHOLD && this.stringDrawn === true) {
|
||||||
// print('HIT CONTINUE LOOP IN CHECK')
|
|
||||||
//continuing to aim the arrow
|
//continuing to aim the arrow
|
||||||
|
|
||||||
this.aiming = true;
|
this.aiming = true;
|
||||||
|
@ -372,7 +383,6 @@
|
||||||
this.updateArrowPositionInNotch();
|
this.updateArrowPositionInNotch();
|
||||||
|
|
||||||
} else if (this.triggerValue > DRAW_STRING_THRESHOLD && this.stringDrawn === false) {
|
} else if (this.triggerValue > DRAW_STRING_THRESHOLD && this.stringDrawn === false) {
|
||||||
// print('HIT START LOOP IN CHECK');
|
|
||||||
this.arrow = this.createArrow();
|
this.arrow = this.createArrow();
|
||||||
this.playStringPullSound();
|
this.playStringPullSound();
|
||||||
|
|
||||||
|
@ -461,10 +471,14 @@
|
||||||
// rotation: arrowProps.rotation
|
// rotation: arrowProps.rotation
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//actually shoot the arrow and play its sound
|
//actually shoot the arrow and play its sound
|
||||||
Entities.editEntity(this.arrow, arrowProperties);
|
Entities.editEntity(this.arrow, arrowProperties);
|
||||||
this.playShootArrowSound();
|
this.playShootArrowSound();
|
||||||
|
|
||||||
|
var backHand = this.hand === 'left' ? 1 : 0;
|
||||||
|
var haptic = Controller.triggerShortHapticPulse(1, backHand);
|
||||||
|
|
||||||
//clear the strings back to only the single straight one
|
//clear the strings back to only the single straight one
|
||||||
this.deleteStrings();
|
this.deleteStrings();
|
||||||
Entities.editEntity(this.preNotchString, {
|
Entities.editEntity(this.preNotchString, {
|
||||||
|
@ -526,4 +540,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Bow();
|
return new Bow();
|
||||||
});
|
});
|
|
@ -62,24 +62,35 @@ function makeBow() {
|
||||||
shapeType: 'compound',
|
shapeType: 'compound',
|
||||||
compoundShapeURL: COLLISION_HULL_URL,
|
compoundShapeURL: COLLISION_HULL_URL,
|
||||||
script: SCRIPT_URL,
|
script: SCRIPT_URL,
|
||||||
|
collidesWith: 'dynamic,kinematic,static',
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
invertSolidWhileHeld: true
|
invertSolidWhileHeld: true
|
||||||
},
|
},
|
||||||
wearable:{joints:{RightHand:[{x:0.03960523009300232,
|
wearable: {
|
||||||
y:0.01979270577430725,
|
joints: {
|
||||||
z:0.03294898942112923},
|
RightHand: [{
|
||||||
{x:-0.7257906794548035,
|
x: 0.03960523009300232,
|
||||||
y:-0.4611682891845703,
|
y: 0.01979270577430725,
|
||||||
z:0.4436084032058716,
|
z: 0.03294898942112923
|
||||||
w:-0.25251442193984985}],
|
}, {
|
||||||
LeftHand:[{x:0.0055799782276153564,
|
x: -0.7257906794548035,
|
||||||
y:0.04354757443070412,
|
y: -0.4611682891845703,
|
||||||
z:0.05119767785072327},
|
z: 0.4436084032058716,
|
||||||
{x:-0.14914104342460632,
|
w: -0.25251442193984985
|
||||||
y:0.6448180079460144,
|
}],
|
||||||
z:-0.2888556718826294,
|
LeftHand: [{
|
||||||
w:-0.6917579770088196}]}}
|
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);
|
Entities.deleteEntity(preNotchString);
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
Loading…
Reference in a new issue