mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:57:59 +02:00
Different model, different sounds, release interval
This commit is contained in:
parent
0865f94106
commit
c55d627e9b
2 changed files with 37 additions and 23 deletions
|
@ -31,9 +31,9 @@ var pingPongGun = Entities.addEntity({
|
||||||
script: scriptURL,
|
script: scriptURL,
|
||||||
position: center,
|
position: center,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 0.1,
|
x:0.67,
|
||||||
y: 0.06,
|
y: 0.14,
|
||||||
z: 0.03
|
z: 0.09
|
||||||
},
|
},
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
|
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var SHOOTING_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/Switches%20and%20sliders/flashlight_on.wav';
|
var SHOOTING_SOUND_URL = 'http://hifi-public.s3.amazonaws.com/sounds/ping_pong_gun/pong_sound.wav';
|
||||||
|
|
||||||
|
|
||||||
function PingPongGun() {
|
function PingPongGun() {
|
||||||
return;
|
return;
|
||||||
|
@ -22,20 +21,36 @@
|
||||||
|
|
||||||
//if the trigger value goes below this value, reload the gun.
|
//if the trigger value goes below this value, reload the gun.
|
||||||
var RELOAD_THRESHOLD = 0.95;
|
var RELOAD_THRESHOLD = 0.95;
|
||||||
var GUN_TIP_FWD_OFFSET = -0.08;
|
var GUN_TIP_FWD_OFFSET = -0.55;
|
||||||
var GUN_TIP_UP_OFFSET = 0.020;
|
var GUN_TIP_UP_OFFSET = 0.040;
|
||||||
var GUN_FORCE = 5;
|
var GUN_FORCE = 15;
|
||||||
|
var BALL_RESTITUTION = 0.6;
|
||||||
|
var BALL_LINEAR_DAMPING = 0.4;
|
||||||
var BALL_GRAVITY = {
|
var BALL_GRAVITY = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: -1,
|
y: -9.8,
|
||||||
z: 0
|
z: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var BALL_DIMENSIONS = {
|
||||||
|
x: 0.04,
|
||||||
|
y: 0.04,
|
||||||
|
z: 0.04
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var BALL_COLOR = {
|
||||||
|
red: 255,
|
||||||
|
green: 255,
|
||||||
|
blue: 255
|
||||||
|
}
|
||||||
|
|
||||||
PingPongGun.prototype = {
|
PingPongGun.prototype = {
|
||||||
hand: null,
|
hand: null,
|
||||||
whichHand: null,
|
whichHand: null,
|
||||||
gunTipPosition: null,
|
gunTipPosition: null,
|
||||||
canShoot: false,
|
canShoot: false,
|
||||||
|
canShootTimeout: null,
|
||||||
setRightHand: function() {
|
setRightHand: function() {
|
||||||
this.hand = 'RIGHT';
|
this.hand = 'RIGHT';
|
||||||
},
|
},
|
||||||
|
@ -53,16 +68,23 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
continueNearGrab: function() {
|
continueNearGrab: function() {
|
||||||
|
|
||||||
if (this.whichHand === null) {
|
if (this.whichHand === null) {
|
||||||
//only set the active hand once -- if we always read the current hand, our 'holding' hand will get overwritten
|
//only set the active hand once -- if we always read the current hand, our 'holding' hand will get overwritten
|
||||||
this.setWhichHand();
|
this.setWhichHand();
|
||||||
} else {
|
} else {
|
||||||
|
if (this.canShootTimeout !== null) {
|
||||||
|
Script.clearTimeout(this.canShootTimeout);
|
||||||
|
}
|
||||||
this.checkTriggerPressure(this.whichHand);
|
this.checkTriggerPressure(this.whichHand);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseGrab: function() {
|
releaseGrab: function() {
|
||||||
this.canShoot = false;
|
var _t = this;
|
||||||
|
this.canShootTimeout = Script.setTimeout(function() {
|
||||||
|
_t.canShoot = false;
|
||||||
|
}, 250)
|
||||||
},
|
},
|
||||||
|
|
||||||
checkTriggerPressure: function(gunHand) {
|
checkTriggerPressure: function(gunHand) {
|
||||||
|
@ -89,20 +111,12 @@
|
||||||
forwardVec = Vec3.multiply(forwardVec, GUN_FORCE);
|
forwardVec = Vec3.multiply(forwardVec, GUN_FORCE);
|
||||||
var properties = {
|
var properties = {
|
||||||
type: 'Sphere',
|
type: 'Sphere',
|
||||||
color: {
|
color: BALL_COLOR,
|
||||||
red: 255,
|
dimensions: BALL_DIMENSIONS,
|
||||||
green: 255,
|
linearDamping: BALL_LINEAR_DAMPING,
|
||||||
blue: 255
|
|
||||||
},
|
|
||||||
dimensions: {
|
|
||||||
x: 0.02,
|
|
||||||
y: 0.02,
|
|
||||||
z: 0.02
|
|
||||||
},
|
|
||||||
linearDamping: 0.2,
|
|
||||||
gravity: BALL_GRAVITY,
|
gravity: BALL_GRAVITY,
|
||||||
|
restitution: BALL_RESTITUTION,
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
collisionSoundURL: SHOOTING_SOUND_URL,
|
|
||||||
rotation: gunProperties.rotation,
|
rotation: gunProperties.rotation,
|
||||||
position: this.getGunTipPosition(gunProperties),
|
position: this.getGunTipPosition(gunProperties),
|
||||||
velocity: forwardVec,
|
velocity: forwardVec,
|
||||||
|
@ -116,7 +130,7 @@
|
||||||
|
|
||||||
playSoundAtCurrentPosition: function(position) {
|
playSoundAtCurrentPosition: function(position) {
|
||||||
var audioProperties = {
|
var audioProperties = {
|
||||||
volume: 0.25,
|
volume: 0.1,
|
||||||
position: position
|
position: position
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue