fixed conflicts

This commit is contained in:
Eric Levin 2015-11-13 17:10:02 -08:00
commit 4e9be8cdd0
3 changed files with 21 additions and 10 deletions

View file

@ -17,7 +17,7 @@ Script.include("../libraries/constants.js");
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
var fireSound = SoundCache.getSound("https://s3.amazonaws.com/hifi-public/sounds/Guns/GUN-SHOT2.raw");
var LASER_LENGTH = 10;
var LASER_LENGTH = 100;
var LASER_WIDTH = 2;
var GUN_FORCE = 10;
var POSE_CONTROLS = [Controller.Standard.LeftHand, Controller.Standard.RightHand];
@ -139,6 +139,7 @@ var kickback = function(animationProperties) {
function fire(side, value) {
print("FIRE")
if (value == 0) {
return;
}
@ -156,9 +157,10 @@ function fire(side, value) {
var intersection = Entities.findRayIntersection(pickRay, true);
if (intersection.intersects) {
print("INTERSECTION")
Script.setTimeout(function() {
if (shootAnything && intersection.properties.collisionsWillMove === true) {
createEntityHitEffect(intersection.intersection);
if (shootAnything && intersection.properties.collisionsWillMove === 1) {
// Any entity with collisions will move can be shot
Entities.editEntity(intersection.entityID, {
velocity: Vec3.multiply(shotDirection, GUN_FORCE)
@ -167,13 +169,17 @@ function fire(side, value) {
} else {
}
//Attempt to call entity method's shot method
var forceDirection = JSON.stringify({
forceDirection: shotDirection
});
Entities.callEntityMethod(intersection.entityID, 'onShot', [forceDirection]);
}, 50);
}
}
function
function scriptEnding() {
mapping.disable();
@ -318,7 +324,7 @@ function createMuzzleFlash(position) {
Script.setTimeout(function() {
Entities.editEntity(smoke, {
isEmitting: false
})
});
}, 100);
var flash = Entities.addEntity({

View file

@ -16,17 +16,22 @@
var _this;
Rat = function() {
_this = this;
this.forceMultiplier = 10.0
this.forceMultiplier = 10;
};
Rat.prototype = {
onHit: function(myId, params) {
onShot: function(myId, params) {
var data = JSON.parse(params[0]);
var force = Vec3.multiply(data.forceDirection, this.forceMultiplier);
Entities.editEntity(this.entityID, {
velocity: force
});
Script.setTimeout(function() {
var vel = Entities.getEntityProperties(_this.entityID, 'velocity').velocity;
print("velocity length " + Vec3.length(vel));
}, 1000);
},
preload: function(entityID) {

View file

@ -1,6 +1,6 @@
var scriptURL = Script.resolvePath('rat.js');
var naturalDimensions = {x: 11.31, y: 3.18, z: 2.19};
var sizeScale = 0.1;
var sizeScale = 0.2;
var dimensions = Vec3.multiply(naturalDimensions, sizeScale);
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation())));
var rat = Entities.addEntity({
@ -13,7 +13,7 @@ var rat = Entities.addEntity({
color: {red: 200, green: 20, blue: 200},
gravity: {x: 0, y: -9.8, z: 0},
collisionsWillMove: true,
script: scriptURL,
script: scriptURL
});
function cleanup() {