collisions

This commit is contained in:
James B. Pollack 2015-11-20 15:41:50 -08:00
parent 4efe31f158
commit c98bfca359

View file

@ -41,7 +41,7 @@
var ARROW_TIP_OFFSET = 0.32; var ARROW_TIP_OFFSET = 0.32;
var ARROW_GRAVITY = { var ARROW_GRAVITY = {
x: 0, x: 0,
y: 0, y: -4.8,
z: 0 z: 0
}; };
@ -285,21 +285,22 @@
dimensions: ARROW_DIMENSIONS, dimensions: ARROW_DIMENSIONS,
position: this.bowProperties.position, position: this.bowProperties.position,
collisionsWillMove: false, collisionsWillMove: false,
ignoreForCollisions: false, ignoreForCollisions: true,
collisionSoundURL:ARROW_HIT_SOUND_URL, collisionSoundURL: ARROW_HIT_SOUND_URL,
gravity: ARROW_GRAVITY, gravity: ARROW_GRAVITY,
damping: 0.01, damping: 0.01,
userData: JSON.stringify({ userData: JSON.stringify({
grabbableKey: { grabbableKey: {
invertSolidWhileHeld: true,
grabbable: false grabbable: false
} }
}) })
}); });
var arrowProps = Entities.getEntityProperties(arrow) var arrowProps = Entities.getEntityProperties(arrow)
Script.addEventHandler(arrow, "collisionWithEntity", function(entityA, entityB, collision) { Script.addEventHandler(arrow, "collisionWithEntity", function(entityA, entityB, collision) {
//have to reverse lookup the tracker by the arrow id to get access to the children //have to reverse lookup the tracker by the arrow id to get access to the children
print('ARROW COLLIDED WITH::' + entityB); print('ARROW COLLIDED WITH::' + entityB);
print('NAME OF ENTITY:::' + Entities.getEntityProperties(entityB, "name").name) print('NAME OF ENTITY:::' + Entities.getEntityProperties(entityB, "name").name)
@ -426,6 +427,8 @@
position: Vec3.sum(this.bowProperties.position, TOP_NOTCH_OFFSET), position: Vec3.sum(this.bowProperties.position, TOP_NOTCH_OFFSET),
dimensions: LINE_DIMENSIONS, dimensions: LINE_DIMENSIONS,
visible: true, visible: true,
ignoreForCollisions: true,
collisionsWillMove: false,
userData: JSON.stringify({ userData: JSON.stringify({
grabbableKey: { grabbableKey: {
grabbable: false grabbable: false
@ -603,6 +606,7 @@
//var forwardVec = Vec3.multiply(handToNotch, handToNotch); //var forwardVec = Vec3.multiply(handToNotch, handToNotch);
var arrowProperties = { var arrowProperties = {
// rotation: arrowRotation, // rotation: arrowRotation,
ignoreForCollisions: false,
collisionsWillMove: true, collisionsWillMove: true,
velocity: forwardVec, velocity: forwardVec,
// lifetime: 10 // lifetime: 10