LukaG
LukaG

Reputation: 43

Unity ARKit automatically positions terrain on startup

I just started learning ARKit with Unity. I've downloaded SDK from Asset store, imported it, opened demo scene and added a terrain. I've added it under HitCubeParent as a child:

http://shrani.si/f/40/UP/1q7QqoFl/1/capture.jpg

I've added a Unity AR Hit Test Example Script on a terrain and linked HitCubeParent to it:

http://shrani.si/f/6/133/3w5sasQA/1/capture1.jpg

When I build a game on iPhone, ARKit is working, but one thing that bothers me is that terrain is positioned automatically when scene starts (even though i don't tap on the screen). It causes bad positioning like terrain floating in the air or similar issues. I would like to modify the kit so when the scene starts, only generated blue plane is visible. User should then adjust the position of a plane to a table or similar flat surface and tap on the screen to position the terrain on that plane.

Like this: https://www.youtube.com/watch?v=OCzuNnejwy4

Any good tutorials on this ? I've searched a lot but couldn't find anything usefull.

Upvotes: 0

Views: 536

Answers (1)

ARMatt
ARMatt

Reputation: 89

Disable the Terrain and enable it after the first successful ARHitTestResult. See line 68 in UnityARHitTestExample.cs:

if (HitTestWithResultType (point, resultType))
{
    return;
}

This is actually confusing since this HitTest method actually positions the m_HitTransform and is not merely a test. In this if block you could enable your terrain, after you disabled it in the Awake method.

Upvotes: 1

Related Questions