From c22a07bba7be404299b053f0235965ee936ffa2c Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Mon, 23 Nov 2015 12:36:39 -0800 Subject: [PATCH] bow collisions, etc --- examples/toybox/bow/bow.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/toybox/bow/bow.js b/examples/toybox/bow/bow.js index 7971b27466..cc851f47f6 100644 --- a/examples/toybox/bow/bow.js +++ b/examples/toybox/bow/bow.js @@ -270,8 +270,13 @@ }); - Script.addEventHandler(arrow, "collisionWithEntity", function(entityA, entityB, collision) { + var makeArrowStick = function(entityA, entityB, collision) { Entities.editEntity(entityA, { + angularVelocity: { + x: 0, + y: 0, + z: 0 + }, velocity: { x: 0, y: 0, @@ -282,10 +287,14 @@ y: 0, z: 0 }, + position: collision.contactPoint, collisionsWillMove: false }) print('ARROW COLLIDED WITH::' + entityB); - }); + Script.removeEventHandler(arrow, "collisionWithEntity", makeArrowStick) + } + + Script.addEventHandler(arrow, "collisionWithEntity", makeArrowStick); return arrow }, @@ -549,6 +558,7 @@ //make the arrow physical, give it gravity, a lifetime, and set our velocity var arrowProperties = { collisionsWillMove: true, + ignoreForCollisions:false, velocity: releaseVelocity, gravity: ARROW_GRAVITY, lifetime: 10,