From 29c4ac83c0b7d503f0402c32a52db1d55550f455 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 24 Feb 2016 18:00:57 -0800 Subject: [PATCH] can set launch position in userdata --- .../fireworksLaunchButtonEntityScript.js | 18 ++++++++---------- .../fireworks/fireworksLaunchButtonSpawner.js | 1 + 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js index ac609418fd..15d9b7d4bd 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js +++ b/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js @@ -34,20 +34,18 @@ }, shootFireworks: function() { + // Get launch position + var launchPosition = getEntityUserData(_this.entityID).launchPosition || _this.position; + var numMissles = randInt(1, 5); for(var i = 0; i < numMissles; i++) { - _this.shootMissle(); + _this.shootMissle(launchPosition); } }, - shootMissle: function() { - var rocketPosition = Vec3.sum(_this.position, { - x: 0, - y: 0.1, - z: 0 - }); + shootMissle: function(launchPosition) { Audio.playSound(_this.launchSound, { - position: rocketPosition, + position: launchPosition, volume: 0.5 }); @@ -63,7 +61,7 @@ var missle = Entities.addEntity({ type: "Model", modelURL: MODEL_URL, - position: rocketPosition, + position: launchPosition, rotation: missleRotation, dimensions: missleDimensions, damping: 0, @@ -80,7 +78,7 @@ visible: false }); - var smokeTrailPosition = Vec3.sum(rocketPosition, Vec3.multiply(-missleDimensions.y / 2 + 0.1, Quat.getUp(missleRotation))); + var smokeTrailPosition = Vec3.sum(launchPosition, Vec3.multiply(-missleDimensions.y / 2 + 0.1, Quat.getUp(missleRotation))); var smokeSettings = { type: "ParticleEffect", position: smokeTrailPosition, diff --git a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js index 831afc18f1..9e0bca8a8d 100644 --- a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js +++ b/examples/playa/fireworks/fireworksLaunchButtonSpawner.js @@ -30,6 +30,7 @@ }, script: SCRIPT_URL, userData: JSON.stringify({ + launchPosition: {x: 1, y: 1.8, z: -20.9}, grabbableKey: { wantsTrigger: true }