Hey all, Student looking for a hand here!
Im trying to render geographical data in an AR App using unity and ARCore. My complication is that i can’t get the AR world to be aligned with real life north, here’s what i’m currently trying:
I have set my XRorigin as a public property, and set it through the editor, i then set it’s rotation to point towards north, or atleast what the device believes to be north. This seems to work and i have verified with debug statements, it gets a rotation.
public XROrigin arSessionOrigin;
public void SetARNorth()
{
arSessionOrigin.transform.rotation = Quaternion.Euler(0f, -trueHeading, 0f);
}
i then spawn a prefab as such, with toPlace being a property set through the editor as with the XRorigin
GameObject SpawnObjectAtUTMCoordinates(GameObject toPlace, Vector3 startCoords, Vector3 stopCoords, UnityEngine.Color color)
{
startCoords = ToUnityCoords(startCoords);
stopCoords = ToUnityCoords(stopCoords);
Vector3 direction = stopCoords - startCoords;
float distance = direction.magnitude;
direction.Normalize();
Quaternion rotation = Quaternion.LookRotation(direction);
//var pipe = Instantiate(toPlace, arSessionOrigin.transform, false); attempted this aswell, didn’t seem to work
var pipe = Instantiate(toPlace, startCoords - offset, Quaternion.identity);
pipe.transform.localRotation = rotation;
pipe.transform.localScale = new Vector3(toPlace.transform.localScale.x * 2, toPlace.transform.localScale.y * 2, distance);
//Set the color of the prefab
pipe.GetComponent().material.color = color;
return pipe;
}
If anyone could give me a hand that would be much appreciated!