@TreyK-47 it doesn’t seem to work but I am not sure if its because I am implementing this incorrectly.
- Pose Driver starts at (0,0,0) and the AR device moves around and let’s say they are at (5,6,8)
- I want to “spawn” the AR player at (1,3,-4) (so the equivalent of reseting the Pose Driver to (0,0,0) but at (1,3,-4))
I would like the response after setting origin to new location to be the value of the new location.
Note 1:
Calling MakeContentAppearAt() seems to be additive?
What I am doing:
float3 newPostTranslation = (some value)
quaternion newPostRotation = (some value)
Transform dummyTransform = new GameObject().transform;
m_ARSessionOrigin.MakeContentAppearAt(dummyTransform, newPoseTranslation, newPoseRotation);
If I call this several times the AR position seems to “travel forward”.
Below you can see the Debug.Log() of the following steps:
- Getting a spawn position
- Calculating where the camera should be (relative to the spawn position it’s (0,2,-10)
- After calling MakeContentAppearAt I log the camera transform
spawn position is: float3(-2.11f, 9.44f, 16.13f)
ARPoseSampler:Update()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
calculated camera position is: float3(-2.11f, 11.44f, 6.129999f)
ARPoseSampler:Update()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
transform after MakeContentAppearAt: (2.2, -11.4, -6.1)
ARPoseSampler:Update()
It appears to be -1 of where I want it to be.
Weirder still is that as I call it more times the offset seems to change based on previous calls. Seems like maybe I need an equivalent “clear” call before I call it again?
I am going to save each update, reverse it, then apply the new one *-1
Note 2:
I got it working by saving the last update, reversing it, then creating the new update
Transform dummyTransform = new GameObject().transform;
//First we will undo our last MakeContentAppearAt
m_ARSessionOrigin.MakeContentAppearAt(dummyTransform, -1f*m_LastPosition, Quaternion.Inverse(m_LastRotation));
//Now we will do our current MakeContentAppearAt
m_LastPosition = -1f * newPoseTranslation;
m_LastRotation = Quaternion.Inverse(newPoseRotation);
m_ARSessionOrigin.MakeContentAppearAt(dummyTransform, m_LastPosition, m_LastRotation);
Result from Debug.Log:
spawn position is: float3(6.33f, 9.88f, 2.03f)
ARPoseSampler:Update()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
calculated camera position is: float3(6.33f, 11.88f, -7.97f)
ARPoseSampler:Update()
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
transform after MakeContentAppearAt: (6.3, 11.9, -8.0)
ARPoseSampler:Update()
This isn’t great because rounding errors causes it to drift away from being correct. Is there anyway to “reset” so I can 0 out? Should I adjust the actual ARSessionOrigin’s Translation and Rotation?