slower rats, pop from stack

This commit is contained in:
James B. Pollack 2015-11-17 13:24:34 -08:00
parent bb7328e476
commit 3d2dc5a7a2
2 changed files with 15 additions and 6 deletions

View file

@ -23,7 +23,6 @@ var RAT_DIMENSIONS = {
z: 1.14
};
var RAT_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/james/rat/ratrotated.fbx';
var RAT_RUNNING_ANIMATION_URL = 'http://hifi-content.s3.amazonaws.com/james/rat/walk.fbx';
var RAT_DEATH_ANIMATION_URL = 'http://hifi-content.s3.amazonaws.com/james/rat/death.fbx';
@ -120,7 +119,7 @@ var targetProperties = {
y: 1,
z: 1
},
visible:false,
visible: false,
position: RAT_NEST_LOCATION
// script: Script.resolvePath('rat.js')
};
@ -189,7 +188,7 @@ function addAvoiderBlock(position) {
position: position,
collisionsWillMove: false,
ignoreForCollisions: true,
visible:false
visible: false
};
var avoider = Entities.addEntity(avoiderProperties);
@ -342,6 +341,15 @@ function removeRatFromScene(rat) {
Entities.deleteEntity(rat);
}
function popRatFromStack(entityID) {
var index = rats.indexOf(entityID);
if (index > -1) {
rats.splice(index, 1);
}
}
Entities.deletingEntity.connect(popRatFromStack);
function cleanup() {
while (rats.length > 0) {
Entities.deleteEntity(rats.pop());
@ -354,6 +362,7 @@ function cleanup() {
Entities.deleteEntity(target);
Script.update.disconnect(moveRats);
Script.update.disconnect(updateTweens);
Entities.deletingEntity.disconnect(popRatFromStack);
Script.clearInterval(ratSpawnerInterval);
}
@ -364,7 +373,7 @@ var ratSpawnerInterval;
if (USE_CONSTANT_SPAWNER === true) {
ratSpawnerInterval = Script.setInterval(function() {
addRat();
// playRatRunningAnimation(rat);
playRatRunningAnimation(rat);
rats.push(rat);
}, RAT_SPAWN_RATE);
}

View file

@ -146,8 +146,8 @@ function arrive(thisEntity, target) {
var properties = Entities.getEntityProperties(thisEntity, ["position", "velocity"]);
var location = properties.position;
var velocity = properties.velocity;
var MAX_SPEED = 16;
var MAX_FORCE = 12;
var MAX_SPEED = 12;
var MAX_FORCE = 8;
var ARRIVAL_DISTANCE = 3;
var desired = Vec3.subtract(targetPosition, location);