I’m engaged on a Cocos 3D undertaking and have run right into a physics problem with two inflexible our bodies:
Once I click on the higher physique, it drops freely into the decrease groove—however as quickly because it contacts the groove, it jitters and finally falls out of the display screen. What I truly need is:
- As soon as it settles within the groove, and no exterior forces are performing on it, it ought to stay completely nonetheless.
- If an exterior power is later utilized, it ought to reply usually to that power.
Right here’s a brief demo of the issue:
Each nodes use the identical BoxItem
script. Related snippets observe:
// Referred to as each body
protected replace(dt: quantity): void {
const rigidBodies = this.node.getComponentsInChildren(RigidBody);
for (const physique of rigidBodies) {
// Stop any undesirable spin when mounted
if (this.isFixed) {
physique.setAngularVelocity(v3(0, 0, 0));
}
}
}
// Initialization (e.g. onLoad)
const rigidBodies = this.node.getComponentsInChildren(RigidBody);
for (const physique of rigidBodies) {
physique.sort = RigidBody.Kind.DYNAMIC;
physique.useGravity = true;
physique.angularFactor = v3(0, 0, 1); // Solely permit rotation round Z
if (this._boxModel?.mass) {
physique.mass = this._boxModel.mass;
}
}
What I’ve Tried So Far
- Clamping angular velocity to zero when
isFixed
- Guaranteeing each our bodies use the identical mass and gravity settings
Desired Conduct
- After the higher physique falls into the groove, it ought to come to relaxation and keep precisely in place if no different forces act on it.
- If one other power (e.g. a collision or person interplay) is later utilized, it ought to react usually.
Questions
- What’s inflicting that steady jitter when it first contacts the groove?
- Which physics properties (e.g., linear/angular damping, friction, contact/collision margins) ought to I alter to let it stabilize and lock in place?
Thanks upfront for any insights or suggestions!