Skip to content

Commit 54dc214

Browse files
committed
Add vertical offset in the direction the object is placed on the plane.
1 parent f6d6683 commit 54dc214

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Scripts/ARPlaceObjectOnPlane.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public void PlaceObjectOnPlane(Pose pose, ARPlane plane)
5555

5656
objectToPlaceGameObject.SetActive(true);
5757

58-
objectToPlaceGameObject.transform.position = pose.position + new Vector3(0, verticalOffset, 0);
58+
objectToPlaceGameObject.transform.position =
59+
pose.position + pose.up.normalized * verticalOffset;
60+
5961
objectToPlaceGameObject.transform.rotation = pose.rotation;
6062

6163
if (plane.alignment.Equals(PlaneAlignment.None) || plane.alignment.Equals(PlaneAlignment.NotAxisAligned))

Scripts/ARShowPlacementMarkerOnPlane.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public void ShowPlacementMarkerOnPlane(bool planeVisible, Pose pose, ARPlane pla
5656

5757
_placementMarkerGameObject.SetActive(true);
5858

59-
_placementMarkerGameObject.transform.position = pose.position + new Vector3(0, verticalOffset, 0);
59+
_placementMarkerGameObject.transform.position =
60+
pose.position + pose.up.normalized * verticalOffset;
61+
6062
_placementMarkerGameObject.transform.rotation = pose.rotation;
6163

6264
if (plane.alignment.Equals(PlaneAlignment.None) ||

0 commit comments

Comments
 (0)