mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:21:16 +02:00
Detect moving objects before catching them
This commit is contained in:
parent
a758ccd75a
commit
2d6c51ac77
1 changed files with 26 additions and 23 deletions
|
@ -48,10 +48,10 @@ var rightHandEntity = false;
|
||||||
var newSound = SoundCache.getSound("https://dl.dropboxusercontent.com/u/1864924/hifi-sounds/throw.raw");
|
var newSound = SoundCache.getSound("https://dl.dropboxusercontent.com/u/1864924/hifi-sounds/throw.raw");
|
||||||
var catchSound = SoundCache.getSound("https://dl.dropboxusercontent.com/u/1864924/hifi-sounds/catch.raw");
|
var catchSound = SoundCache.getSound("https://dl.dropboxusercontent.com/u/1864924/hifi-sounds/catch.raw");
|
||||||
var throwSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Switches%20and%20sliders/slider%20-%20whoosh1.raw");
|
var throwSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/Switches%20and%20sliders/slider%20-%20whoosh1.raw");
|
||||||
var targetRadius = 1.0;
|
var targetRadius = 0.25;
|
||||||
|
|
||||||
|
|
||||||
var wantDebugging = false;
|
var wantDebugging = true;
|
||||||
function debugPrint(message) {
|
function debugPrint(message) {
|
||||||
if (wantDebugging) {
|
if (wantDebugging) {
|
||||||
print(message);
|
print(message);
|
||||||
|
@ -120,30 +120,33 @@ function checkControllerSide(whichSide) {
|
||||||
var closestEntity = Entities.findClosestEntity(palmPosition, targetRadius);
|
var closestEntity = Entities.findClosestEntity(palmPosition, targetRadius);
|
||||||
|
|
||||||
if (closestEntity.isKnownID) {
|
if (closestEntity.isKnownID) {
|
||||||
|
var foundProperties = Entities.getEntityProperties(closestEntity);
|
||||||
|
if (Vec3.length(foundProperties.velocity) > 0.0) {
|
||||||
|
|
||||||
debugPrint(handMessage + " HAND- CAUGHT SOMETHING!!");
|
debugPrint(handMessage + " - Catching a moving object!");
|
||||||
|
|
||||||
if (whichSide == LEFT_PALM) {
|
if (whichSide == LEFT_PALM) {
|
||||||
leftBallAlreadyInHand = true;
|
leftBallAlreadyInHand = true;
|
||||||
leftHandEntity = closestEntity;
|
leftHandEntity = closestEntity;
|
||||||
} else {
|
} else {
|
||||||
rightBallAlreadyInHand = true;
|
rightBallAlreadyInHand = true;
|
||||||
rightHandEntity = closestEntity;
|
rightHandEntity = closestEntity;
|
||||||
|
}
|
||||||
|
var ballPosition = getBallHoldPosition(whichSide);
|
||||||
|
var properties = { position: { x: ballPosition.x,
|
||||||
|
y: ballPosition.y,
|
||||||
|
z: ballPosition.z },
|
||||||
|
rotation: palmRotation,
|
||||||
|
color: HELD_COLOR,
|
||||||
|
velocity : { x: 0, y: 0, z: 0},
|
||||||
|
gravity: { x: 0, y: 0, z: 0}
|
||||||
|
};
|
||||||
|
Entities.editEntity(closestEntity, properties);
|
||||||
|
|
||||||
|
Audio.playSound(catchSound, { position: ballPosition });
|
||||||
|
|
||||||
|
return; // exit early
|
||||||
}
|
}
|
||||||
var ballPosition = getBallHoldPosition(whichSide);
|
|
||||||
var properties = { position: { x: ballPosition.x,
|
|
||||||
y: ballPosition.y,
|
|
||||||
z: ballPosition.z },
|
|
||||||
rotation: palmRotation,
|
|
||||||
color: HELD_COLOR,
|
|
||||||
velocity : { x: 0, y: 0, z: 0},
|
|
||||||
gravity: { x: 0, y: 0, z: 0}
|
|
||||||
};
|
|
||||||
Entities.editEntity(closestEntity, properties);
|
|
||||||
|
|
||||||
Audio.playSound(catchSound, { position: ballPosition });
|
|
||||||
|
|
||||||
return; // exit early
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue