ping pong gun

This commit is contained in:
James Pollack 2015-10-02 15:56:26 -07:00
parent c6fa132dc2
commit 9427ba1a5a
2 changed files with 13 additions and 10 deletions

View file

@ -13,8 +13,8 @@ Script.include("../../utilities.js");
var scriptURL = Script.resolvePath('pingPongGun.js');
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun.fbx'
var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun_collision_hull.obj';
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun.fbx?123'
var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun_collision_hull.obj?123';
var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
x: 0,
@ -30,9 +30,9 @@ var pingPongGun = Entities.addEntity({
script: scriptURL,
position: center,
dimensions: {
x:0.67,
y: 0.14,
z: 0.09
x: 0.08,
y: 0.21,
z: 0.47
},
collisionsWillMove: true,
});
@ -40,4 +40,4 @@ var pingPongGun = Entities.addEntity({
function cleanUp() {
Entities.deleteEntity(pingPongGun);
}
Script.scriptEnding.connect(cleanUp);
Script.scriptEnding.connect(cleanUp);

View file

@ -81,15 +81,14 @@
},
releaseGrab: function() {
var _t = this;
var _this = this;
if (this.whichHand === this.hand) {
_t.whichHand = null;
this.whichHand = null;
this.canShootTimeout = Script.setTimeout(function() {
_t.canShoot = false;
_this.canShoot = false;
}, 250);
}
},
checkTriggerPressure: function(gunHand) {
@ -107,6 +106,7 @@
this.shootBall(gunProperties);
this.canShoot = false;
}
return;
},
@ -114,6 +114,7 @@
var forwardVec = Quat.getFront(Quat.multiply(gunProperties.rotation, Quat.fromPitchYawRollDegrees(0, -90, 0)));
forwardVec = Vec3.normalize(forwardVec);
forwardVec = Vec3.multiply(forwardVec, GUN_FORCE);
var properties = {
type: 'Sphere',
color: BALL_COLOR,
@ -148,8 +149,10 @@
var frontOffset = Vec3.multiply(frontVector, GUN_TIP_FWD_OFFSET);
var upVector = Quat.getRight(properties.rotation);
var upOffset = Vec3.multiply(upVector, GUN_TIP_UP_OFFSET);
var gunTipPosition = Vec3.sum(properties.position, frontOffset);
gunTipPosition = Vec3.sum(gunTipPosition, upOffset);
return gunTipPosition;
},