timer fix for reset

This commit is contained in:
ericrius1 2015-09-10 16:46:25 -07:00
parent 510e253575
commit a1fd867c09
2 changed files with 19 additions and 5 deletions

View file

@ -25,6 +25,8 @@
running: true running: true
}); });
var timeSinceLastMoved = 0;
var RESET_TIME_THRESHOLD = 5;
var RESET_POSITION = { var RESET_POSITION = {
x: 549.12, x: 549.12,
y: 495.555, y: 495.555,
@ -48,6 +50,17 @@
this.update = function(deltaTime) { this.update = function(deltaTime) {
self.getUserData(); self.getUserData();
self.properties = Entities.getEntityProperties(self.entityId); self.properties = Entities.getEntityProperties(self.entityId);
timeSinceLastMoved += deltaTime;
if (Vec3.length(self.properties.velocity) < 0.1) {
if (timeSinceLastMoved > RESET_TIME_THRESHOLD) {
self.reset();
timeSinceLastMoved = 0;
}
} else {
timeSinceLastMoved = 0;
}
if (self.userData.grabKey && self.userData.grabKey.activated === true) { if (self.userData.grabKey && self.userData.grabKey.activated === true) {
if (self.activated !== true) { if (self.activated !== true) {
Entities.editEntity(self.paintStream, { Entities.editEntity(self.paintStream, {
@ -62,7 +75,6 @@
animationSettings: stopSetting animationSettings: stopSetting
}); });
self.activated = false; self.activated = false;
self.reset();
} }
} }
@ -150,9 +162,9 @@
blue: randInt(190, 250) blue: randInt(190, 250)
}, },
dimensions: { dimensions: {
x: 5, x: 50,
y: 5, y: 50,
z: 5 z: 50
}, },
lifetime: 100 lifetime: 100
}); });

View file

@ -8,7 +8,9 @@
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
var scriptURL = "https://hifi-public.s3.amazonaws.com/scripts/entityScripts/sprayPaintCan.js"; //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";
// var scriptURL = "https://hifi-public.s3.amazonaws.com/scripts/entityScripts/sprayPaintCan.js";
// var scriptURL = "file:////Users/ericlevin/hifi/examples/entityScripts/sprayPaintCan.js?=v1" + Math.random(); // var scriptURL = "file:////Users/ericlevin/hifi/examples/entityScripts/sprayPaintCan.js?=v1" + Math.random();
var modelURL = "https://hifi-public.s3.amazonaws.com/eric/models/paintcan.fbx"; var modelURL = "https://hifi-public.s3.amazonaws.com/eric/models/paintcan.fbx";
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Camera.getOrientation()))); var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));