Physics rigid bodies, Pendulum Instances

In learning physics engines, I cannot determine if there is a bug or it`s my question.

In official cases,it is very normal

new BABYLON.PhysicsAggregate(box, BABYLON.PhysicsShapeType.BOX, { mass: 1 }, scene);

:grinning:
I am trying to use my own understanding to implement this case study.
Firstly I implemented it on PG, the hpBodyId property reported an error
image

and then, I implement this function in a local environment,
I tried debugging and didn’t find the problem about the hpBodyId, It does indeed have value

But my experiment was also unsuccessful,the second parameter instanceIndex of setMotionType and setMassProperties did not fulfill its intended function

// this.mesh.physicsBody?.setMotionType(BABYLON.PhysicsMotionType.DYNAMIC, 0)
// this.mesh.physicsBody?.setMassProperties({ mass: 1 }, 0)

this.mesh.physicsBody?.setMotionType(BABYLON.PhysicsMotionType.DYNAMIC, 1)
this.mesh.physicsBody?.setMassProperties({ mass: 1 }, 1)

I think I see what’s going wrong.
1 box and 1 physics body are created and then instances are added 1 by 1.
But the physics is not updated to take these new instances.
I’d suggest to add the mesh and all its instances and then to create the physics body.

1 Like

In this case, the first instance is stationary, and the following instances can oscillate

first instance set

this.mesh.physicsBody?.setMotionType(BABYLON.PhysicsMotionType.STATIC, 0)
this.mesh.physicsBody?.setMassProperties({ mass: 0 }, 0)

other instance set

this.mesh.physicsBody?.setMotionType(BABYLON.PhysicsMotionType.DYNAMIC, 1)
this.mesh.physicsBody?.setMassProperties({ mass: 1 }, 1)

Implementing different instances of the same object exhibit different physical properties (setMassProperties and setMotionType)

you are right :kissing_heart:
At first, I didn’t understand. I tried as you told me, and there was no problem
there is a sequence of setting between objects and physical body

1 Like