3

I’ve been learning about RealityKit lately, and have come across Reality Composer. However, it seems that in the app the user can only have one anchor at a time.

I was wondering if it is at all possible to have two anchors in a scene, a vertical and a horizontal. I’m trying to detect a floor and walls that can interact with physics bodies and need both for the game to properly function.

I don’t need to know the positions or anything about the vertical anchors, I just need them to have physics bodies.

Does Reality Composer allow for more than one anchor in a scene? I know that RealityKit allows for this, but I don’t know if scenes created in Reality Composer can.

1 Answer 1

2

Reality Composer v1.5 can't allow you to simultaneously use two different types of Anchors at the moment. Here are five types of Anchors you can use in RC (and only one anchor per one scene):

  • Horizontal (à la ARPlaneAnchor)
  • Vertical (à la ARPlaneAnchor)
  • Image (à la ARImageAnchor)
  • Face (à la ARFaceAnchor)
  • Object (à la ARObjectAnchor)

But you can use two different types of Anchors at a time in RealityKit.

In RealityKit there are three types of alignment:

AnchoringComponent.Target.Alignment.horizontal
AnchoringComponent.Target.Alignment.vertical

/* Entity can be anchored to surfaces of Any alignment */
AnchoringComponent.Target.Alignment.any       

An Alignment struct conforms to OptionSet protocol, so you can use 2 types simultaneously:

let anchor = AnchorEntity(plane: [.horizontal, .vertical],
                  minimumBounds: [0.2, 0.2])

or you can setup it through AnchoringComponent:

anchor.anchoring = AnchoringComponent(.plane(.any, 
                             classification: .any, 
                              minimumBounds: [0.1, 0.1]))

or you can use reanchor() instance method:

let houseScene = try! Experience.loadHouseScene()

houseScene.reanchor(.plane(.any, classification: .any, 
                                  minimumBounds: [0.1, 0.1]), 
                       preservingWorldTransform: false)

You can read this story to find out how it looks like in real code.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.