mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
Bots will move
This commit is contained in:
parent
6c27b99aba
commit
4da6af96bb
2 changed files with 31 additions and 6 deletions
|
@ -17,12 +17,19 @@ function getRandomInt (min, max) {
|
||||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
// choose a random x and y in the range of 0 to 50
|
var CHANCE_OF_MOVING = 0.05;
|
||||||
positionX = getRandomFloat(0, 18);
|
var isMoving = false;
|
||||||
positionZ = getRandomFloat(0, 18);
|
|
||||||
|
var STARTING_RANGE = 18.0;
|
||||||
|
var MOVE_RANGE = 1.0;
|
||||||
|
var STOP_TOLERANCE = 0.05;
|
||||||
|
var MOVE_RATE = 0.10;
|
||||||
|
var firstPosition = { x: getRandomFloat(0, STARTING_RANGE), y: 0, z: getRandomFloat(0, STARTING_RANGE) };
|
||||||
|
var targetPosition = { x: 0, y: 0, z: 0 };
|
||||||
|
|
||||||
|
|
||||||
// change the avatar's position to the random one
|
// change the avatar's position to the random one
|
||||||
Avatar.position = {x: positionX, y: 0, z: positionZ};
|
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);
|
||||||
|
@ -52,4 +59,21 @@ Avatar.faceModelURL = "https://s3-us-west-1.amazonaws.com/highfidelity-public/me
|
||||||
Avatar.skeletonModelURL = "https://s3-us-west-1.amazonaws.com/highfidelity-public/meshes/" + newBodyFilePrefix + ".fst";
|
Avatar.skeletonModelURL = "https://s3-us-west-1.amazonaws.com/highfidelity-public/meshes/" + newBodyFilePrefix + ".fst";
|
||||||
Avatar.billboardURL = "https://dl.dropboxusercontent.com/u/1864924/bot-billboard.png";
|
Avatar.billboardURL = "https://dl.dropboxusercontent.com/u/1864924/bot-billboard.png";
|
||||||
|
|
||||||
Agent.isAvatar = true;
|
Agent.isAvatar = true;
|
||||||
|
|
||||||
|
function updateBehavior() {
|
||||||
|
if (!isMoving && (Math.random() < CHANCE_OF_MOVING)) {
|
||||||
|
// Set new target location
|
||||||
|
targetPosition = { x: Avatar.position.x + getRandomFloat(-MOVE_RANGE, MOVE_RANGE),
|
||||||
|
y: Avatar.position.y,
|
||||||
|
z: Avatar.position.z + getRandomFloat(-MOVE_RANGE, MOVE_RANGE) };
|
||||||
|
isMoving = true;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
Avatar.position = Vec3.sum(Avatar.position, Vec3.multiply(Vec3.subtract(targetPosition, Avatar.position), MOVE_RATE));
|
||||||
|
if (Vec3.length(Vec3.subtract(Avatar.position, targetPosition)) < STOP_TOLERANCE) {
|
||||||
|
isMoving = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Script.willSendVisualDataCallback.connect(updateBehavior);
|
||||||
|
|
|
@ -79,7 +79,8 @@ var addSound3 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-publi
|
||||||
var deleteSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+delete+2.raw");
|
var deleteSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+delete+2.raw");
|
||||||
var changeColorSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+edit+2.raw");
|
var changeColorSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Voxels/voxel+edit+2.raw");
|
||||||
var clickSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Switches+and+sliders/toggle+switch+-+medium.raw");
|
var clickSound = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Switches+and+sliders/toggle+switch+-+medium.raw");
|
||||||
var audioOptions = new AudioInjectionOptions();
|
var audioOptions = new AudioInjectionOptions();
|
||||||
|
|
||||||
audioOptions.volume = 0.5;
|
audioOptions.volume = 0.5;
|
||||||
audioOptions.position = Vec3.sum(MyAvatar.position, { x: 0, y: 1, z: 0 } ); // start with audio slightly above the avatar
|
audioOptions.position = Vec3.sum(MyAvatar.position, { x: 0, y: 1, z: 0 } ); // start with audio slightly above the avatar
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue