mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 22:44:15 +02:00
tweaking distance threshold
This commit is contained in:
parent
a1fd867c09
commit
7969fb64ce
2 changed files with 9 additions and 8 deletions
|
@ -27,12 +27,12 @@
|
|||
|
||||
var timeSinceLastMoved = 0;
|
||||
var RESET_TIME_THRESHOLD = 5;
|
||||
var RESET_POSITION = {
|
||||
var DISTANCE_FROM_HOME_THRESHOLD = .5;
|
||||
var HOME_POSITION = {
|
||||
x: 549.12,
|
||||
y: 495.555,
|
||||
z: 503.77
|
||||
};
|
||||
|
||||
this.getUserData = function() {
|
||||
|
||||
|
||||
|
@ -51,13 +51,14 @@
|
|||
self.getUserData();
|
||||
self.properties = Entities.getEntityProperties(self.entityId);
|
||||
|
||||
timeSinceLastMoved += deltaTime;
|
||||
if (Vec3.length(self.properties.velocity) < 0.1) {
|
||||
if (Vec3.length(self.properties.velocity) < 0.1 && Vec3.distance(HOME_POSITION, self.properties.position) > DISTANCE_FROM_HOME_THRESHOLD) {
|
||||
timeSinceLastMoved += deltaTime;
|
||||
if (timeSinceLastMoved > RESET_TIME_THRESHOLD) {
|
||||
self.reset();
|
||||
timeSinceLastMoved = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
timeSinceLastMoved = 0;
|
||||
}
|
||||
|
||||
|
@ -80,7 +81,7 @@
|
|||
|
||||
this.reset = function() {
|
||||
Entities.editEntity(self.entityId, {
|
||||
position: RESET_POSITION,
|
||||
position: HOME_POSITION,
|
||||
rotation: Quat.fromPitchYawRollDegrees(0, 0, 0),
|
||||
angularVelocity: ZERO_VEC,
|
||||
velocity: ZERO_VEC
|
||||
|
|
|
@ -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";
|
||||
var scriptURL = "https://hifi-public.s3.amazonaws.com/eric/scripts/sprayPaintCan.js?=v1" + Math.random();
|
||||
// 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 modelURL = "https://hifi-public.s3.amazonaws.com/eric/models/paintcan.fbx";
|
||||
|
@ -30,7 +30,7 @@ var sprayCan = Entities.addEntity({
|
|||
shapeType: 'box',
|
||||
script: scriptURL,
|
||||
gravity: {x: 0, y: -0.5, z: 0},
|
||||
velocity: {x: 0, y: -.01, z: 0}
|
||||
velocity: {x: 0, y: -1, z: 0}
|
||||
});
|
||||
|
||||
function cleanup() {
|
||||
|
|
Loading…
Reference in a new issue