paint can tweaks

This commit is contained in:
ericrius1 2015-09-16 09:59:35 -07:00
parent da208526cc
commit 0b21cc1777
2 changed files with 10 additions and 2 deletions

View file

@ -57,7 +57,8 @@
timeSinceLastMoved = 0;
}
if (self.userData.grabKey && self.userData.grabKey.activated === true) {
//Only activate for the user who grabbed the object
if (self.userData.grabKey && self.userData.grabKey.activated === true && this.userData.grabKey.avatarId == MyAvatar.sessionUUID) {
if (self.activated !== true) {
//We were just grabbed, so create a particle system
self.grab();
@ -105,6 +106,7 @@
this.letGo = function() {
this.activated = false;
Entities.deleteEntity(this.paintStream);
this.paintStream = null;
}
this.reset = function() {
@ -208,6 +210,8 @@
this.entityId = entityId;
this.properties = Entities.getEntityProperties(self.entityId);
this.getUserData();
//Only activate for the avatar who is grabbing the can!
if (this.userData.grabKey && this.userData.grabKey.activated) {
this.activated = true;
}
@ -227,6 +231,9 @@
this.unload = function() {
Script.update.disconnect(this.update);
if(this.paintStream) {
Entities.deleteEntity(this.paintStream);
}
this.strokes.forEach(function(stroke) {
Entities.deleteEntity(stroke);
});

View file

@ -9,7 +9,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//Just temporarily using my own bucket here so others can test the entity. Once PR is tested and merged, then the entity script will appear in its proper place in S3, and I wil switch it
var scriptURL = "https://hifi-public.s3.amazonaws.com/eric/scripts/sprayPaintCan.js?=v3";
var scriptURL = "https://hifi-public.s3.amazonaws.com/eric/scripts/sprayPaintCan.js?=v6";
var modelURL = "https://hifi-public.s3.amazonaws.com/eric/models/paintcan.fbx";
var sprayCan = Entities.addEntity({
@ -37,3 +37,4 @@ function cleanup() {
}
Script.scriptEnding.connect(cleanup);