Determine distance between foot and world space object
Hi there, I'm trying to determine the distance between a detected foot and an object in world space. However the distance value that I'm getting back doesn't seem correct. I would expect it to drop to near 0 as I get close to the object in my scene, however it just sort of stays around 3 point something. Furthermore, when I print out the position of the foot, it almost feels like the values I'm getting are relative to the camera position, and not a static world origin.
I wrote a simple script to get distance like so
// -----JS CODE-----
//@input SceneObject objectA
//@input SceneObject objectB
function setupDistanceCheck() {
if (!(script.objectA && script.objectB)) {
return;
}
var transformA = script.objectA.getTransform();
var transformB = script.objectB.getTransform();
var posA = transformA.getWorldPosition();
var posB = transformB.getWorldPosition();
var ADistB = transformA.getWorldPosition().distance(transformB.getWorldPosition());
global.logToScreen(ADistB, true);
return ADistB;
}
function update(){
var dist = setupDistanceCheck();
}
var updateEvent = script.createEvent("UpdateEvent");
updateEvent.bind(update);
For the foot tracking, I'm using the template project, and I've added another camera with a device tracking component. I've tried in both surface and world tracking mode and the world tracking seems more correct but still something isn't quite right. Any tips on how to work with feet tracking and objects in the world coordinate system?