Open
Description
I just did something quite complex to create a dynamic body without gravity, and then apply gravity when I grab it so it falls when I release it.
boxEl.setAttribute("physx-body", "type: dynamic");
boxEl.setAttribute("toggle-physics", "");
boxEl.addEventListener("componentinitialized", (evt) => {
if (evt.detail.name !== "physx-body") {
return;
}
boxEl.components["physx-body"].physxRegisteredPromise.then(() => {
boxEl.components["physx-body"].toggleGravity();
});
});
boxEl.addEventListener(
"pickup",
() => {
boxEl.components["physx-body"].toggleGravity();
},
{ once: true }
);
The pickup
event is emitted by grab-magnet-target
component (from handy-controls) that toggles the grabbed
state if using toggle-physics component that set the kinematic flag
Lines 953 to 958 in a1271b4
Instead of componentinitialized
listener and using internal physxRegisteredPromise
variable, we should probably add an applyGravity
property to physx-body
.
Metadata
Metadata
Assignees
Labels
No labels