Reality Composer – Attaching entities together in a chain, with physics enabled

Viewed 117

I would like to build a chain of entities in RealityComposer in a way that they are "glued together" at one face each, while individually obeying gravity physics:

example of chained components structure

In this example, the gray component can stay fixed and non-physically interacting, to the face, but I would like the other chain components to be able to move and behave like an elephant's trunk.

The auto-generated code for these components in Experience.swift is very basic, and appears also to be read-only, so I don't understand how to take it further from a coding perspective:

public class Trunk: RealityKit.Entity, RealityKit.HasAnchoring {

    public var anchorSegement: RealityKit.Entity? {
        return self.findEntity(named: "AnchorSegement")
    }

    public var segment1: RealityKit.Entity? {
        return self.findEntity(named: "Segment_1")
    }

    public var segment2: RealityKit.Entity? {
        return self.findEntity(named: "Segment_2")
    }

    public var segment3: RealityKit.Entity? {
            return self.findEntity(named: "Segment_3")
    }
}
1 Answers

To implement a life-like physics simulation where each linked part of model obeys gravity (chain effect), you should choose one of the two ways (but at the moment, no one of them is supported in Reality Composer 1.5 or RealityKit 2.0).

Skeleton (joints and bones)

Use a Trunk model with an animated skeletal rig created in Maya or Blender and exported to .usdz format. Of course, animation isn't the same as dynamics simulation, but animated objects can give you the illusion of the desired effect. However, the way described below is exactly what you need.

Physics Constraint (pin-point)

Instead of RealityKit, use SceneKit where you can use SCNPhysicsBallSocketJoint objects, which will help you implement the linking between one section of the "trunk" and next one, thanks to physical constraints. Usually, physics simulation and rendering like this, comes at a very high processing cost (mostly due to collisions of physical bodies).

Related