Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

Re-position World Origin #304

Open
CJRobertson opened this issue Jul 11, 2018 · 7 comments
Open

Re-position World Origin #304

CJRobertson opened this issue Jul 11, 2018 · 7 comments

Comments

@CJRobertson
Copy link

CJRobertson commented Jul 11, 2018

I was wondering if there is a built in way to re-position the world origin after the AR session starts? To be a bit more specific, ARKit 1.5 has this exact same ability:(https://developer.apple.com/documentation/arkit/arsession/2942278-setworldorigin)

The ideal solution would be to tap on a tracked plane and the entire origin would move to that tapped position.

@pablisho
Copy link
Contributor

pablisho commented Jul 19, 2018

Hi, thanks for the feature request. Currently ARCore does not support resetting the world origin. I think what you can do is to add an Anchor in your desired position and set your object's parent transform to the Anchor's transform. Would that work for your use case?

@CJRobertson
Copy link
Author

That unfortunately will not work.

The purpose of what I'm asking for would help situations like spectating a traditional multiplayer game like Call of Duty for example (not an AR multiplayer game using cloud anchors). Everything is based off the game's server so if I were to move CoD player #1 in AR (using your suggestion that would then move that player in the AR app's game world position), as soon as the player sends movement data to the server, the server will snap player #1's location on the AR app back to the server position.

For a bit more clarification, let's pretend like the server says the CoD player #1 is camping at location 100, 50, 40 (Unity game world coordinates). If I were to move that player in AR to say 500, 265, 300 (still in Unity game world coordinates), the server will still think that player is camping at 100, 50, 40. You wouldn't have an issue until the player sent movement data to the server. So if the player starts moving and ends up at 150, 70, 40, the server will snap the player in the AR app to that new location forcing you to have to constantly move the player.

That's just one example, but the same idea applies to anything that requires objects placed in Unity editor to stay at their placed location in game world coordinates.

@pnarendr
Copy link

@pablisho , what you suggested would work for me: I need to establish anchors relative to a permanent augmented image marker and find them again in a new session. Can you please help with some pointers on how to achieve this (elaborate on your comment"I think what you can do is to add an Anchor in your desired position and set your object's parent transform to the Anchor's transform" with some pseudocode perhaps?

@aefox
Copy link

aefox commented Sep 6, 2018

@pnarendr the unity android cloud anchors example has this exact same code you're looking for. here's the gist:

// Instantiate Andy model at the hit pose.
var andyObject = Instantiate(_GetAndyPrefab(), m_LastPlacedAnchor.transform.position, m_LastPlacedAnchor.transform.rotation);

// Compensate for the hitPose rotation facing away from the raycast (i.e. camera).
andyObject.transform.Rotate(0, k_ModelRotation, 0, Space.Self);

// Make Andy model a child of the anchor.
andyObject.transform.parent = m_LastPlacedAnchor.transform;

Here's the github link for the code.

@pnarendr
Copy link

pnarendr commented Sep 6, 2018 via email

@pnarendr
Copy link

pnarendr commented Sep 7, 2018

BTW, is there a corresponding code using Android ARCore?

@rvilardo
Copy link

is there any updates on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants