Merge pull request #2199 from PhilipRosedale/master

Adjustable bot pelvis height
This commit is contained in:
ZappoMan 2014-03-04 18:47:01 -08:00
commit 2e3e699e31
2 changed files with 13 additions and 6 deletions

View file

@ -18,6 +18,10 @@ function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min; return Math.floor(Math.random() * (max - min + 1)) + min;
} }
function printVector(string, vector) {
print(string + " " + vector.x + ", " + vector.y + ", " + vector.z);
}
var CHANCE_OF_MOVING = 0.005; var CHANCE_OF_MOVING = 0.005;
var CHANCE_OF_SOUND = 0.005; var CHANCE_OF_SOUND = 0.005;
var CHANCE_OF_HEAD_TURNING = 0.05; var CHANCE_OF_HEAD_TURNING = 0.05;
@ -31,6 +35,7 @@ var X_MIN = 0.0;
var X_MAX = 5.0; var X_MAX = 5.0;
var Z_MIN = 0.0; var Z_MIN = 0.0;
var Z_MAX = 5.0; var Z_MAX = 5.0;
var Y_PELVIS = 2.5;
var MOVE_RANGE_SMALL = 0.5; var MOVE_RANGE_SMALL = 0.5;
var MOVE_RANGE_BIG = Math.max(X_MAX - X_MIN, Z_MAX - Z_MIN) / 2.0; var MOVE_RANGE_BIG = Math.max(X_MAX - X_MIN, Z_MAX - Z_MIN) / 2.0;
@ -41,7 +46,7 @@ var TURN_RATE = 0.15;
var PITCH_RATE = 0.20; var PITCH_RATE = 0.20;
var PITCH_RANGE = 30.0; var PITCH_RANGE = 30.0;
var firstPosition = { x: getRandomFloat(X_MIN, X_MAX), y: 0, z: getRandomFloat(Z_MIN, Z_MAX) }; var firstPosition = { x: getRandomFloat(X_MIN, X_MAX), y: Y_PELVIS, z: getRandomFloat(Z_MIN, Z_MAX) };
var targetPosition = { x: 0, y: 0, z: 0 }; var targetPosition = { x: 0, y: 0, z: 0 };
var targetDirection = { x: 0, y: 0, z: 0, w: 0 }; var targetDirection = { x: 0, y: 0, z: 0, w: 0 };
var currentDirection = { x: 0, y: 0, z: 0, w: 0 }; var currentDirection = { x: 0, y: 0, z: 0, w: 0 };
@ -72,9 +77,6 @@ function playRandomSound(position) {
} }
} }
// change the avatar's position to the random one
Avatar.position = firstPosition;
// pick an integer between 1 and 20 for the face model for this bot // pick an integer between 1 and 20 for the face model for this bot
botNumber = getRandomInt(1, 100); botNumber = getRandomInt(1, 100);
@ -103,6 +105,10 @@ Avatar.billboardURL = "https://s3-us-west-1.amazonaws.com/highfidelity-public/me
Agent.isAvatar = true; Agent.isAvatar = true;
// change the avatar's position to the random one
Avatar.position = firstPosition;
printVector("New bot, position = ", Avatar.position);
function updateBehavior() { function updateBehavior() {
if (Math.random() < CHANCE_OF_SOUND) { if (Math.random() < CHANCE_OF_SOUND) {
playRandomSound(Avatar.position); playRandomSound(Avatar.position);
@ -132,6 +138,7 @@ function updateBehavior() {
} }
targetPosition.x = clamp(targetPosition.x, X_MIN, X_MAX); targetPosition.x = clamp(targetPosition.x, X_MIN, X_MAX);
targetPosition.z = clamp(targetPosition.z, Z_MIN, Z_MAX); targetPosition.z = clamp(targetPosition.z, Z_MIN, Z_MAX);
targetPosition.y = Y_PELVIS;
isMoving = true; isMoving = true;
} else { } else {

View file

@ -57,12 +57,12 @@ function shootBullet(position, velocity) {
damping: 0 }); damping: 0 });
// Play firing sounds // Play firing sounds
audioOptions.position = position; audioOptions.position = position;
Audio.playSound(fireSound, audioOptions); Audio.playSound(fireSound, audioOptions);
} }
function particleCollisionWithVoxel(particle, voxel) { function particleCollisionWithVoxel(particle, voxel) {
var HOLE_SIZE = 0.25; var HOLE_SIZE = 0.125;
var particleProperties = Particles.getParticleProperties(particle); var particleProperties = Particles.getParticleProperties(particle);
var position = particleProperties.position; var position = particleProperties.position;
Particles.deleteParticle(particle); Particles.deleteParticle(particle);