Forum Discussion

gubendran_vins's avatar
gubendran_vins
Honored Guest
14 days ago

MRUK: Object not automatically placed on floor in Meta XR SDK 78

Hi everyone,

I am working on a Mixed Reality project using Meta XR SDK v78 with MR Utility Kit (MRUK) in Unity 6000.0.55f1

I want to automatically place a 3D machine model on the real-world floor when the scene loads.

However, the object stays floating in mid-air instead of being positioned on the detected floor surface.

Here’s the code I tried:

var room = MRUK.Instance.GetCurrentRoom();

if (room != null)

{

var anchor = room.GetSurface(MRUKAnchor.SceneLabels.FLOOR);

if (anchor != null)

{

transform.position = anchor.transform.position;

transform.rotation = anchor.transform.rotation;

}

}

But, this does not align with the real world in the floor it is in the mid air please let me know to how to fix this.

Thanks in advance.

2 Replies

  • Hey gubendran_vins!

    I'm sorry to hear that you're having trouble getting your object to spawn in the right place, I understand how that could be irritating. Regarding the issue you mentioned, my first suggestion would be to use the MRUK surface utilities to find the closest point on the detected floor surface. If the anchor's origin is misplaced and you've set the object's transform to the anchor's transform, it's possible that the anchor's pose is offset from the real floor and the object won't spawn in the place you want.

    If you're still having trouble getting the object to spawn in the right place, you could also try using the Environment Raycasting API to more precisely place your object. We have some great documentation that covers each of these topics, and I can link the pages below. 

    Hope this helps, and please feel free to let me know if you have any questions or need any more help!

    Spatial Anchors
    Mixed Reality Utility Kit – Manage and query scene data
    Mixed Reality Utility Kit – Place content with scene data
    Mixed Reality Utility Kit – Instant placement with Environment Raycasting API

    -G

  • Hi gubendran_vins​ ! I've faced a similar problem based on my past experience with MRUK anchor placement. The solution I've recalled is to make sure that the pivot origin of your 3D machine model is at the exact lowest centre of the base.

    Let us know again whether this solves your problem - if so, you can mark as solved! 😄

→ Find helpful resources to begin your development journey in Getting Started

→ Get the latest information about HorizonOS development in News & Announcements.

→ Access Start program mentor videos and share knowledge, tutorials, and videos in Community Resources.

→ Get support or provide help in Questions & Discussions.

→ Show off your work in What I’m Building to get feedback and find playtesters.

→ Looking for documentation?  Developer Docs

→ Looking for account support?  Support Center

→ Looking for the previous forum?  Forum Archive

→ Looking to join the Start program? Apply here.

 

Recent Discussions