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.
Asked
Active
Viewed 288 times
2
-
1you can make the two the children of a upper entity, then rotate the upper one? – Hassan Apr 23 '21 at 22:34
1 Answers
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
-
1Thanks! 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