Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
3.04k stars 1.14k forks source link

How to use AR Foundation's AR Camera without all the other features #1117

Closed smart09091 closed 9 months ago

smart09091 commented 11 months ago

How do I use AR Foundation's AR Camera without all the other features? I currently have a project with my own gyro controls. I've basically faked AR controls by moving the camera around and I'd like to use AR Foundation's AR Camera as a background to have a pseudo AR experience but I think AR Foundation is fighting with my app's current world space coordinates as the game objects would sometimes have really janky movement like things would just move really fast out of game camera view so with that is there any way to disable all the other features/ components of AR Foundation and just use the AR Camera? I dont know which object specifically I need to disable but I think it has something to do with how objects are being tracked by AR Foundation or if its something else I'd really appreciate any help on how to achieve this

andyb-unity commented 11 months ago

What you ask isn't exactly possible. To be clear, you cannot mix and match any third-party tracking solution with AR Camera tracking. The TrackedPoseDriver component on your Main Camera GameObject (assuming your scene is set up like this: https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@5.1/manual/project-setup/scene-setup.html) will write the Camera position every frame.

The AR Camera feature is dependent on there being an active AR Session in the scene. AR Sessions have certain properties that you need to take into account when designing your app, such as relocalizing when they learn more about the environment. This means that you cannot rely on world-space coordinates to place GameObjects in space.

If you want to place objects relative to the camera, you should Instantiate them as children of the Main Camera GameObject.

If you want to place objects at a known location in space, you should use Anchors (https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@5.1/manual/features/anchors.html). Anchors are designed by AR platforms as a way to place content such that its position is preserved even as the session relocalizes.

If your app can't be built under these constraints, then ARCore / ARKit might not be the best tool for what you are trying to do.

andyb-unity commented 9 months ago

Closing this issue as asked and answered. Feel free to re-open it if you have further questions.