RealityKit - How can I calculate distance between two anchorEntity?

there's position which is simd3 and there 's anchorEntity. I want to get distance between two.

how I did is

var distance = distance(position, ( self.modelentity.position(relativeTo:nil) )
var distance = distance(position, ( self.modelentity.position )

but both failed because it seems calculating distance between world origin anchor not distance between position to self.modelentity.

how can I calculate distance ?

Post not yet marked as solved Up vote post of kotran Down vote post of kotran
1.3k views

Replies

Hi, can you expand your code snippet a bit? How are you calculating the first position value?

For world space something like this should work:

let distance = simd_distance(entityA.position(relativeTo: nil), entityB.position(relativeTo: nil))