2

Is there an easy way to interact with several ModelEntities in RealityKit at the same time? for example rotate two ModelEntities with one multi-touch gesture.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Negar Bean
  • 65
  • 9

1 Answers1

3

Of course you can. Just create a parent entity for two or more children.

let parentEntity = Entity()
parentEntity.addChild(childEntity01)
parentEntity.addChild(childEntity02)
    
arView.installGestures([.all], for: parentEntity as! Entity & HasCollision)

P. S.

Also, this post will show you how raycasting works in conjunction with RealityKit gestures.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • 1
    Thanks! I was getting `Thread 1: EXC_BREAKPOINT (code=1, subcode=0x10428c3a0)` on the `arView.installGestures([.all], for: parentEntity as! Entity & HasCollision)` line. I changed parentEntity to ModelEntity and it's fixed now. – Negar Bean Apr 26 '21 at 10:57