# AR Foundation - Calculate AR Camera height relative to tracked plane

Hi Guys

How would I go about doing this, taking into account my AR Session Origin currently has a scale of 250, but can be scaled in realtime.

When placing my prefab on the plane, I actually want to place it ABOVE the plane, but a set height BELOW the camera’s height. So for example if my camera is 160cm from the ground (and so also the detected plane), I want my object to be placed on the plane, (so 0 in Y), but then 40cm below the camera height, so the object gets raised to 120cm in other words. OR, it get’s put on same Y level as the camera, but then lowered -40cm.

Makes sense? Further, if the detected plane was on a table, then naturally my camera’s height might be lower relative to the detected plane, so in that case the camera height might be 30cm from the plane. In that case I can’t place my model -40cm from the cam since then it will be below the table. That logic is easy to work out with an if then else.

I just need to understand how to get the initial height of the cam above the plane in real world units, even though AR Session may be scaled. Ones I have the height of the cam, the rest should be relative simple isnt it, unless the scaling of AR session will make things complicated.

Cant you Just raycast down from the camera to infiniteplane, then subtract the position vectors?

I need to know the plane the prefab is placed on. The infinite plane is always on the ground isnt it?

Also, “raycast down”, doesnt tell me anything the hint should be in my forum name…
A line of code or a link with examples, could help

Watch this video and you will understand measuring distances between two points.

I am pretty new to Unity, but I thing this will help you. You can check.

if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
if (m_SessionOrigin.Raycast(touch.position, s_Hits, TrackableType.PlaneWithinPolygon))
{
Pose hitPose = s_Hits[0].pose;

Transform cameraTransform = Camera.main.transform;

float originYPosition = m_SessionOrigin.transform.y
float cameraYposition = cameraTransform.position.y
float floorYPosition = hitPose.position.y;

=========== Origin ===============

=========== Camera ===============

| |
| |
| |
| |
| |
=========== Floor ===============