mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 05:33:10 +02:00
moved barrel point forward so ray doesnt hit gun
This commit is contained in:
parent
d4c7b6b9b9
commit
53f75e305a
2 changed files with 16 additions and 8 deletions
|
@ -22,8 +22,11 @@
|
|||
this.equipped = false;
|
||||
this.forceMultiplier = 1;
|
||||
this.laserOffsets = {
|
||||
y: .15
|
||||
y: .15,
|
||||
};
|
||||
this.firingOffsets = {
|
||||
z: 0.3
|
||||
}
|
||||
};
|
||||
|
||||
Pistol.prototype = {
|
||||
|
@ -48,13 +51,14 @@
|
|||
var gunProps = Entities.getEntityProperties(this.entityID, ['position', 'rotation']);
|
||||
var position = gunProps.position;
|
||||
var rotation = gunProps.rotation;
|
||||
var direction = Quat.getFront(rotation);
|
||||
this.firingDirection = Quat.getFront(rotation);
|
||||
var upVec = Quat.getUp(rotation);
|
||||
position = Vec3.sum(position, Vec3.multiply(upVec, this.laserOffsets.y));
|
||||
var tip = Vec3.sum(position, Vec3.multiply(direction, 10));
|
||||
this.barrelPoint = Vec3.sum(position, Vec3.multiply(upVec, this.laserOffsets.y));
|
||||
var laserTip = Vec3.sum(this.barrelPoint, Vec3.multiply(this.firingDirection, 10));
|
||||
this.barrelPoint = Vec3.sum(this.barrelPoint, Vec3.multiply(this.firingDirection, this.firingOffsets.z))
|
||||
Overlays.editOverlay(this.laser, {
|
||||
start: position,
|
||||
end: tip,
|
||||
start: this.barrelPoint,
|
||||
end: laserTip,
|
||||
alpha: 1
|
||||
});
|
||||
},
|
||||
|
@ -89,7 +93,11 @@
|
|||
},
|
||||
|
||||
fire: function() {
|
||||
print("FIRE!");
|
||||
var pickRay = {origin: this.barrelPoint, direction: this.firingDirection};
|
||||
var intersection = Entities.findRayIntersectionBlocking(pickRay, true);
|
||||
if(intersection.intersects) {
|
||||
print('intersection!');
|
||||
}
|
||||
},
|
||||
|
||||
initControllerMapping: function() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getFront(Camera.getOrientation())));
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));
|
||||
var scriptURL = Script.resolvePath('pistol.js');
|
||||
var modelURL = "https://s3.amazonaws.com/hifi-public/eric/models/gun.fbx";
|
||||
print("SJDJDJ")
|
||||
|
|
Loading…
Reference in a new issue