- Home /
Question by
unity_YchrI2cY-GQVqw · Apr 29, 2019 at 04:44 AM ·
gameobjecttransformlocalscaleanchor
Scale (Transform.localscale) a gameobject based on ARFaceAnchor anchorData
I am using Unity ARKit FaceTracking.
I am placing 3d gameobjects on a persons face however the scale is not accurate. I am wondering how to scale the gameobject based on the anchorData given by ARFaceAnchor.
I have tried to create a face mesh and use the facemesh.bounds.size to scale my gameobject but the scale factor is not correct.
void FaceUpdated (ARFaceAnchor anchorData)
{
if (faceMesh != null) {
sunglassAnchorPrefab.transform.localPosition = UnityARMatrixOps.GetPosition (anchorData.transform);
sunglassAnchorPrefab.transform.localRotation = UnityARMatrixOps.GetRotation(anchorData.transform);
faceMesh.vertices = anchorData.faceGeometry.vertices;
faceMesh.uv = anchorData.faceGeometry.textureCoordinates;
faceMesh.triangles = anchorData.faceGeometry.triangleIndices;
faceMesh.RecalculateBounds();
faceMesh.RecalculateNormals();
}
}
The sunglassAcnhorPrefab position and rotation can be set easily using anchorData but im seriously struggling with the scale.
Comment